...

View Full Version : running 2 ifs at once



TrainReq
03-21-2007, 12:49 AM
How do I run 2 ifs at once , but have the same else... for example

If post password and if post email do query... if both of these or none of these are posted .. echo "Invalid"

shyam
03-21-2007, 12:56 AM
the boolean operator '&&' ;)

goughy000
03-21-2007, 12:56 AM
just combine them into one if



<?php
if($_POST['password'] == "correct password" && $_POST['email'] == "correct@email.com"){
dostuff();
}else{
echo "Invalid";
}
?>




EDIT: u beat my post by like 2 seconds

TrainReq
03-21-2007, 01:04 AM
wat about && $_POST['email'] == "ANYTHING"

BTW:
Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/nightse/public_html/sttest/login.php on line 5

(just make sure email was posted period)

aedrin
03-21-2007, 04:19 PM
Post the entire line you tried. Otherwise we can't see what went wrong.

goughy000
03-21-2007, 06:30 PM
if you just want to check that an email was set and not that is is a certain value

so thats dosnt = nothing and is set


<?php
if($_POST['password'] == "correct password" && $_POST['email'] != "" && isset($_POST['email'])){
echo "ok";
}else{
echo "Invalid";
}
?>
your error sounds like you missed a ; earlier on in the script



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum