Jump to content

Archived

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

Mig

Help a PHP noob please

Recommended Posts

Hi, I've just started learning PHP, and I'm trying to finish a contact form I've made.

I have [i]contact.htm [/i] which goes to [i]mailer.php[/i]. I have written some JavaScript validation of the form, and I am going to use server-side validation too. Problem is, (let's say JS is turned off) I have no idea how to go back to the contact form if the input is incorrect, with the values still in the fields, then display the relevant error message.

I was thinking I could have some error messages with [b]display:none[/b], which I then switch to [b]display:inline[/b] but I really have no idea how to do that with PHP (if you can at all).

Ok, basically, how do I send the user back to contact.htm after PHP validation fails, with the form remaining as it was, and alert them to the errors?

Thanks.

[b]Edit:[/b] I understand how to do it if I just use one php page. Is this advisable?

Share this post


Link to post
Share on other sites
You can do it all in one page... there's no reason against doing this.

BUT, if you wanted to use 2, you could easily do your validiation on mailer.php and if the validation failes, simply use the header() function to redirect them.  You still have to change the form page to a php page and include the error messages in case you have to go back and so on and so on. 

Long story short, it's easier to do it all within the same page and leave the validation to PHP.

Share this post


Link to post
Share on other sites

×

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.