views:

106

answers:

3

Hi, I need help creating the php for my contact form, here is the form = http://keironlowe.byethost17.com/contact.html

What I need is, the text that says "This field is required" to only appear if the person didn't fill in them fields, and if the message was sent successfully I need it to redirect the user to another page.

Thankyou so much in advance!

A: 

By default you do not need to show the The field is required text. Upon receiving the contents of the form you should check whether all fields are filled in.

If fields are missing you show the form again (with the provided information) and for the empty/invalid fields you show the texts. Otherwise you redirect using the header("Location: url") method.

Veger
+2  A: 

First, you need to do the validation using javasciprt. After that, you do the processing if form is validated and redirect the user using the header function:

header("location: path/page here");

See More: PHP Form Basics

Sarfraz
A: 

in principle, you can either do this using plain html on the client side or via javascript. Assuming from the given link that we are dealing with plain html, your receiving script (the link that is called when the user presses "send", in your case "PHP/mailer.php") must check the fields and then either redisplay the page with the warnings included or accepting the submission + redirecting the user.

Bullet Tooth Tony