This post definately belongs in the NUB section. I cant get my IF-ELSE to work ... i think.
This code is supposed to validate two email addressed, if they are of valid length and matches, then validate it against a DB to see if they exist or not and post error codes along the way if anything happens.
When email is not valid length or email doesnt match, it throws the correct errors. Problem is when the email is the correct length AND matches, nothing is printed. Not even simple echo statements that I throw in there to see if it even accesed the correct IF-ELSE.
Its like it skip my entire if-else.
Below is my code. Any help is appreciated.
Thanks.
if((!isset($POST[email])) || (strlen($POST[email]) < 7)){
echo "<LI> A valid email address is required.</LI>";
$mistake = true;
} else {
//if email is set and email 1 matches email2
//checks in db if that email alreadi exists
if($POST[email2] === $POST[email]){
echo "in else set";
$HOST = "localhost";
$DBNAME = "user";
$USER = "wong";
$PASS = "dragon";
//connect to db and validate db-user
$conn_host = mysql_connect($HOST, $USER, $PASS) or die(mysql_error());
$conn_db = mysql_select_db($DBNAME, $conn_host) or die(mysql_error());
$sql = "SELECT FROM user_profile WHERE email ='$_POST[email]'";
$return = mysql_query($sql, $conn_db);
if(mysql_num_rows($return) > 0){
echo "<LI> Your email is alreadi registered with our system, please use another email address.</LI>";
} else {
echo "works <br>";
}
} else {
echo "<LI> Your emails does not match.</LI>";
$mistake = true;
}