I am having trouble getting my if/elses to do what they should. It's probably something dumb that I'm overlooking. Can anyone help?
if(isset($_POST['homePageReg_submit']))
{
$db = new connectDB();
$db->username = "";
$db->password = "";
$db->hostName = "";
$db->dbName = "";
$db->connect();
$rf_username = $_POST['homePageReg_username'];
$rf_email = $_POST['homePageReg_email'];
$rf_validateEmail = new validateEmail();
$rf_validateEmail->email = $rf_email;
//check_email_address returns false if the email address doesnt pass validation.
if($rf_validateEmail->check_email_address())
{
$tempPw = setPw();
$rf_register = new registerUser();
$rf_register->username = $rf_username;
$rf_register->password = $tempPw;
$rf_register->email = $rf_email;
//compareUsernames returns false if either the username of email is already in the database.
if($rf_register->compareUsernames())
{
$rf_register->register();
$activate = new activationEmail();
$activate->username = $rf_username;
$activate->email = $rf_email;
$activate->sendPw();
}
else
{
//username taken
header("location:../../index.php5?regError=1");
}
$db->closeConnection();
}
else
{
//invalid Email
header("location:../../index.php5?regError=2");
}
header("location:../../index.php5?regSuccess=1");
}
The problem is that even when I enter invalid emails or duplicate usernames it still just returns to index.php5?regSuccess=1. It doesn't enter the data into the database or send the email though. So it works, it just doesnt send the user to the right page after the script runs.