Eiolon Posted December 23, 2006 Share Posted December 23, 2006 Hello,I have some code to confirm that passwords match before inserting. I tell the script to die if they don't match. The problem is it removes the form, making the user press the back button to return to it. Is there a way to make it so the form stays when the error appears?Here is my code, thanks![code]// Confirm that the passwords match.if ($_POST['password'] != $_POST['password2']) { die ('Your passwords do not match.');}[/code] Quote Link to comment Share on other sites More sharing options...
Philip Posted December 23, 2006 Share Posted December 23, 2006 You could do something like I do:[code]<?php// Confirm that the passwords match.if ($_POST['password'] != $_POST['password2']) { $error['password'] = true;}if(isset($error)) { /*show errors & form*/ } else { /*continue on with script*/ }?>[/code]You could do that for all of the form variables you want checked. Then, in the form:[code]<?php if($error['password'] == true) { echo "<b>Your passwords did not match</b>";} /*show form*/?>[/code] 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.