Bounty Posted March 17, 2011 Author Share Posted March 17, 2011 I really don't remember erasing that :S Anyhow it works now all the way to: if( !empty($_POST['password2']) ) { // same validations as in name, above. if($_POST['password2'] != $_POST['password']) { $error = 'Passwords do not match.' . $errors[] = $error; } } else { $errors[] = 'Confirm your password.'; } Script always jumps to this error "Confirm your password." even if: [password] => abc [pass_conf] => abc Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 17, 2011 Share Posted March 17, 2011 Look at the field names in the print_r() result, versus what they are in !empty() conditional and the != comparison . . . Quote Link to comment Share on other sites More sharing options...
Bounty Posted March 18, 2011 Author Share Posted March 18, 2011 Fixed that...it was a type mistake...now the final thing... I tried to add [action=do_reg.php] inside form brackets but it wont work..it just jumps over whole script to do_reg.php...so how should i continue the registration after the checking fields...should i add [include 'do_reg.php';] at the end of the php before }? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 Ideally, you should incorporate the logic from do_reg.php into that script, or include it when the form validates without errors. Quote Link to comment Share on other sites More sharing options...
Bounty Posted March 18, 2011 Author Share Posted March 18, 2011 So i should add it after this line: if( (isset($_POST['submitted']) && !empty($errors)) || !isset($_POST['submitted']) ) { But it wont work... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 No. Anything within that conditional will only be executed if the form is submitted with errors, or the form is not submitted. Assuming you want the do_reg script to run when the script has been submitted, and there are NO errors, you would need to add an else{} to go with the if( !empty(errors) ) { conditional. if( !empty($errors) ) { // if the $errors array is not empty, display the errors to allow the user to correct them and resubmit the form echo "<font color=\"red\">The following errors were detected:<br>"; echo implode("<br>\n", $errors); echo '</font>'; } else { // Code here would be executed if the form has been submitted with no errors. } Quote Link to comment Share on other sites More sharing options...
Bounty Posted March 18, 2011 Author Share Posted March 18, 2011 It works almost perfectly but it shows error at: $errors[] = $error; Output: Array ( [username] => aaa [password] => ddd [pass_conf] => sss => aaa [submitted] => yes [submit] => Submit ) Notice: Undefined variable: error in C:\xampp\htdocs\login\register1.php on line 35 The following errors were detected: Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 18, 2011 Share Posted March 18, 2011 I probably shoud butt out since I haven't read the entire discussion, but should that be $errors? As I scan through previous posts, it seems like the variable is usually referred to with an "s" at the end. $errors[] = $errors; Quote Link to comment Share on other sites More sharing options...
Bounty Posted March 21, 2011 Author Share Posted March 21, 2011 I still get errors...:S Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 21, 2011 Share Posted March 21, 2011 For the code back in reply 25, it looks like you have an error: <?php ... $error = 'Passwords do not match.' . $errors[] = $error; ... ?> There should be a semi-colon after the line that assigns the value to $error instead of a period. If that's doesn't fix the issue, it might be helpful to post the most recent code. Quote Link to comment Share on other sites More sharing options...
Bounty Posted March 21, 2011 Author Share Posted March 21, 2011 I didn't notice that :S Thanks a lot believe or not topic is solved it works like a Swiss watch Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 21, 2011 Share Posted March 21, 2011 It's amazing what a little semi-colon can do; or should I say what kind of havoc a missing semi-colon cause. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.