Click to See Complete Forum and Search --> : if statements that wont return negative...


Da Warriah
07-22-2003, 06:59 PM
GGGGGGAAAAAAAAAAAAAHHHHHHHHHH!!!!!!! I HATE THESE STUPID FORMS!!:mad:

there...now that thats out...i have been staring at this code for over an hour, trying a million different things to figure out why it wont work...

i have three input fields in order for the user to change their password if they so desire...however, its optional, and im trying to find a way to determine if the fields are empty or not (to determine whether to change the password or leave it alone)...

the thing is that no matter whether the fields are empty or not, they still return a value back...and even this wont work for some reason:

elseif((!isset($orig) || $orig == "") && (!isset($pw) || $pw == "") && (!isset($pw2) || $pw2 == "")){

can ANYone help me with this? have i suddenly gone insane? YES!! and with good reason...all i need to do is figure out whether those fields are empty or not...

edit: alright ive calmed down a bit now, and ive vowed never to look at that code again until i get a response here...lol...otherwise ill go insane again...;)

pyro
07-22-2003, 10:52 PM
Try using empty() (http://us2.php.net/manual/en/function.empty.php), maybe?

pyro
07-22-2003, 11:03 PM
You original code seems to work ok, as well... Try playing around with which of the first three lines are commented out...

<?PHP
#$orig = "test";
#$pw = "test";
#$pw2 = "test";
if((!isset($orig) || $orig == "") && (!isset($pw) || $pw == "") && (!isset($pw2) || $pw2 == "")){
echo "No variable were set, or the variable were blank";
}
else {
echo "At least one of the variable were set";
}
?>

Da Warriah
07-23-2003, 08:31 AM
Originally posted by pyro
You original code seems to work ok, as well... Try playing around with which of the first three lines are commented out...

lol, well believe me, if it worked, then i wouldnt have sat there for an hour last night about to throw my computer out the window...the problem is that ive got a whole bunch of different if statements to cover all the different options....mostly error messages like "your original password was incorrect" and stuff...but it kept giving me errors even when all of the fields were empty...so anyways, empty() looks promising...thanx

edit: well dont i feel like a fool...i spent over an hour of my life on just trying to figure out why the heck it wouldnt work...turns out, it had nothing to do with blank fields, if statements, or anything...they work great...my stupid $match variable didnt get passed through the form correctly, so it never found the right array for itself...then it overwrote the file with all the arrays with a bunch of blank variables...jeez...anyways thanx for the help, lol (i think i need some professional help, hehe)...

Nevermore
07-24-2003, 06:28 AM
lol