$email = mysql_real_escape_string($_POST['signup-email']);
if(empty($email)){
$status = "error";
$message = "You did not enter an email address!";
}
else if(!preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/', $email)){
$status = "error";
$message = "You have entered an invalid email address!";
}
else {
$existingSignup = mysql_query("SELECT * FROM signups WHERE signup_email_address='$email'");
if(mysql_num_rows($existingSignup) < 1){
$date = date('Y-m-d');
$time = date('H:i:s');
$insertSignup = mysql_query("INSERT INTO signups (signup_email_address, signup_date, signup_time) VALUES ('$email','$date','$time')");
if($insertSignup){ l
$status = "success";
$message = "Success!";
}
else {
$status = "error";
$message = "Ooops, Theres been a technical error!";
}
}
else {
$status = "error";
$message = "This email address has already been registered!";
}
}
$data = array(
'status' => $status,
'message' => $message
);
echo json_encode($data);
exit;
}
__________________________________________________________________________________
Now this all works, emails, dates and times are submitted accordingly to the database, I've tried a fair few things, but can't get It to redirect on a successful entry.
Help would be greatly appreciated, thanks.
E.L Brister,
This method did not work, I've tried that too
Still didn't work, thanks for the help though, It's appreciated.
if(empty($email)){
$status = "error";
$message = "You did not enter an email address!";
}
else if(!preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/', $email)){
$status = "error";
$message = "You have entered an invalid email address!";
}
else {
$existingSignup = mysql_query("SELECT * FROM signups WHERE signup_email_address='$email'");
if(mysql_num_rows($existingSignup) < 1){
$date = date('Y-m-d');
$time = date('H:i:s');
$insertSignup = mysql_query("INSERT INTO signups (signup_email_address, signup_date, signup_time) VALUES ('$email','$date','$time')");
if($insertSignup){ l
$status = "success";
$message = "Success!";
}
else {
$status = "error";
$message = "Ooops, Theres been a technical error!";
}
}
else {
$status = "error";
$message = "This email address has already been registered!";
}
}
$data = array(
'status' => $status,
'message' => $message
);
echo json_encode($data);
exit;
}
__________________________________________________________________________________
Now this all works, emails, dates and times are submitted accordingly to the database, I've tried a fair few things, but can't get It to redirect on a successful entry.
Help would be greatly appreciated, thanks.
E.L Brister,
This method did not work, I've tried that too
Still didn't work, thanks for the help though, It's appreciated.