I need to execute a PHP if statement with javascript without reloading the page. It has to do with a 3-step signup, and I'm having difficulty determining how to move from step 1 to step 2. It also includes an error-catcher to help any faulty sign-ups. My plan for the error-catcher was simple, until I realized passing variables between client and server without reloading the whole page is rather tricky.
The form the data on it is posting to a $_SERVER['PHP_SELF'].
This is the IF statement that needs executing: ($_POST and $_GET can be interchanged whenever necessary in terms of the submitted form data.)
if (isset($_POST['stage1'])) {
//Match the passwords up and ensure they match, else you get an error.
if ($_POST['password1']===$_POST['password2']) {
$userpass=$_POST['password1'];
} else {
$error="Passwords do not match! Please try again.";
}
// Match up the emails and ensure they do, else you get an error.
if ($_POST['email1']===$_POST['email2']) {
$error="Your emails do not match! Please try again.";
}
// Validate the birthday to see if the applicant is over 18....
$CurrDate=date("md");
$ValidYear=date("Y")-18;
// The two above strings gather intergers for the month and day with leading zeroes.
$validation=$ValidYear.$CurrDate; // The final result of a complete date to validate against.
$UserDate=$_POST['year'].$_POST['month'].$_POST['day']; // This is the user's given date of birth.
if ($validation<$UserDate) {
$error="You're not over 18! You cannot apply.";
}
// Carry on the values from this form! (granted there are no errors)
if ($error==NULL) {
$NextStep; //Ignore that this variable is null. It's rather unimportant other than it changes $_POST to $_GET as I had trouble with $_GET...
}
}
The only Javascript I really know is EXTREMELY basic. Mostly because I look at all these tutorials and my head explodes beyond getElementById()
Any help would be greatly appreciated
This post has been edited by the1corrupted: 31 March 2009 - 09:07 PM

New Topic/Question
Reply



MultiQuote





|