Mig Posted September 13, 2006 Share Posted September 13, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/20633-help-a-php-noob-please/ Share on other sites More sharing options...
ober Posted September 13, 2006 Share Posted September 13, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/20633-help-a-php-noob-please/#findComment-91165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.