Jump to content

Form-data validation-error msg-return to form


geronimo

Recommended Posts

1. I have a form that posts data.
2. I have php script that handles data and checks for errors. If no error, it returns page with the data that was entered and a thank you.
3. If there is an error: it returns the user to a blank form and exits the php script.

I want:
1. To at least echo an error message and return user to a blank form.

2. If I could echo an error message and return user to form with the data that they entered still there, that would be better.

I WANT TO USE PHP NOT JAVA SCRIPTS....etc....

Here is what I have:

<?
if ((!$_POST[FirstName]) || (!$_POST[LastName]) ||(!$_POST[BusinessName])|| (!$_POST[Address])
|| (!$_POST[Email]) || (!$_POST[Email2]) || (!$_POST[Category])){
header("Location: http//www.go.back.here/submit_your_business.html");
exit;
}

This checks to see if data was entered in these fields.
If not: it returns user to blank form.

Again: I want to echo a message and then return to the form or return to the form with the message above the form....whichever is appropriate coding.

And then: if I can return the user to the form with an error message and the form still holding the data.....terrific.

Thanks
geronimo


To be able to present the user with a form prefilled with their entries, the script that checks the input should be the same script that presents the form.

The basic flow would be:
[list]
[*]If the form has been submitted, check for errors -- storing the error messages in a variable
[*]If there are no errors -- process the data
[*]If there are errors or the form hasn't been submitted yet display the form. Where ever each field can have a value, display the value retrieved from the last form submission (if any).
[/list]

Keb
1. Maybe I should have mentioned that the FORM is an HTML page....using the  Method = POST and then the ACTION calls the php script.

2. Yes -  as it pertains to the link: http://www.allinthissite.co.uk/index/index.php?page=account&action=home

However, If the user is returned to the form, I would like to be able to present the form with the data still present. If that is too much, I'll take what I can get.


I'm willing to change whatever is necessary. If the form needs to be presented via php as opposed to html, I'll try to do that.


Thanks for responding

geronimo

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.