Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:33:08+00:00 2026-05-26T04:33:08+00:00

So my problem is (aside from being a noob) is that while in my

  • 0

So my problem is (aside from being a noob) is that while in my studeis, im trying to check a couple of things for true/false and no matter how i set my code, if one parameter is met, it goes through as true even though the second parameter is false.

for example, i have a form im working on and i want to know if theres any data entered in the name/pass fields. if not, then redirect back to the form page.

heres whats happening:

html / pseudo:

<html and other header tags>
<form method="post" action="procfile.php">
  <table>
    <tr>
        <td>Username:</td>
        <td><input type="text" name="user" id="user"></td>
    </tr>
    <tr>
        <td>password:</td>
        <td><input type="text" name="password" id="password"></td>
    </tr>
        <tr>
        <td></td>
        <td><input type="submit" value="submit"></td>

    </tr>
</table>

</form>
</html>

as for the php, im checking for empty first, originally i had it like this:

<?php
if((empty($_POST['user']))&&(empty($_POST['password']))){
    header("Location:index.php"); /* Redirect browser */

exit;
}

?>

this doesnt work. i dont get syntax errors or anything…so, after a while i changed to longer version so from above it went to this.

<?php

if(empty($_POST['user'])){
    header("Location:index.php"); /* Redirect browser */


exit;
}  else if((empty($_POST['password']))){
    header("Location:index.php"); /* Redirect browser */


exit;
} 

?>

this also doesn’t work. i took out the else if and did a bunch of if statements together one ontop of another so that if one fails, redirect, if it passes, go down to the next if statement…

this too didn’t work.

the problem overall that im having is (i feel dumb!) is that, on all of these, when the condition of the first value is met, it skips the rest of the php below it and goes ahead to load the html. only happens on the first one only. If for example, i enter password only, it throws me back to index. if i enter username first and not the pass..it lets me through EVEN though, there are other if statements with their own rules. i placed the php ontop of everything to make SURE it was happening b4 anything was being sent but to no avail.

ideas?
what am i doing wrong with these conditionals?

funny thing is when i test for the value of POST against the value of a result in a db(from another script im working on), like so:

if((!empty($user)) && (!empty($pass))) {
    //connect to db
    $connect2db = mysqli_connect('127.0.0.1', 'root', 'pass', 'db');
        if(!$connect2db){
            die("error connectin to Database" . mysqli_error);
        }

    $dbq = "SELECT * FROM accounts;";
    $dbqDoIt = mysqli_query($connect2db, $dbq)or die("error".mysqli_error($connect2db));

    $getNames = mysqli_fetch_array($dbqDoIt);
        //check if user acc. exists inside vS database.
        if(($name === $getNames['username']) && ($pass === $getNames['password'])){
//do something

}

when i check like this with not empty, it stays put UNTIL both conditions are met…when i check for empty (ive tried with !isset too) in the example above, it fails me miserably….

what am i doing wrong? please help.

thank you kindly in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:33:08+00:00Added an answer on May 26, 2026 at 4:33 am

    You need an OR here.

    if(!$_POST['user'] || !$_POST['password']){
        header("Location: index.php"); /* Redirect browser */
        exit;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a specific controller action that is being called twice, which aside from
Aside from scalability issues, has anyone here actually stumbled upon a web-development problem where
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
I am trying to stop a class from being able to convert its 'this'
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: Ajax suggest-search on [ n ] ingredients in recipes. That is: match recipes
Problem: Given a list of strings, find the substring which, if subtracted from the
I have a program that, among other things, needs to be able to refresh
I'm trying to figure out how to solve some challenges that my team is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.