I have a php script that sends the contents of a form via email.

I have some error checking in the script to make sure that the required fields are filled out. Right now, if there's an error, it just displays an error, with what's missing on a simple html page.

I want to be able to have this error appear within a page that looks like the rest of my website.

My question is, how can I pass the error message so that it is displayed on a pre-constructed html page? I don't want to have to create a new page for each error.

Does that make sense?


8 Years
Discussion Span
Last Post by vaultdweller123

There are a couple ways to do it.


2. Self-validating page/form

AJAX is a procedure (not a language) that uses JavaScript, XML, and PHP to dynamically change the contents of a web page without completely reloading it. You would use JavaScript to get information from your form and send it, via XML, to your PHP script. The script would then send information back to the JavaScript on how to update the page. Find more info and a tutorial here.

Another option is a self-validating form. A self-validating form has areas hidden within it for error reporting and sends its data to itself when submitted. Script that executes before the form displays does all the validation and performs the necessary actions if the submission is valid.

Hope that helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.