Jump to content

[SOLVED] Stopping script and echoing on same page.


Eiolon

Recommended Posts

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]
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.