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]
Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.