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] Link to comment https://forums.phpfreaks.com/topic/31650-solved-stopping-script-and-echoing-on-same-page/ 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] Link to comment https://forums.phpfreaks.com/topic/31650-solved-stopping-script-and-echoing-on-same-page/#findComment-146695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.