Jump to content


Photo

Help a PHP noob please


  • Please log in to reply
1 reply to this topic

#1 Mig

Mig
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 September 2006 - 04:00 PM

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

I have contact.htm which goes to mailer.php. 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 display:none, which I then switch to display:inline 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.

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

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 13 September 2006 - 04:30 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users