Hi All

I've checked around all kinds of sites, but to be honest I'm literally just learning PHP and not a clue what people are saying. Basically all I want to do is make some fields required before the form is submitted. At the moment all it does is go to the header:location page when it's submitted! I've probably put something in the wrong place.

My html code is -

<form method="POST" action="contact.php">
          <input type="text" name="name" size="30">
          email <br>
          <input type="text" name="email" size="30">
          message* <br>
          <textarea rows="9" name="message" cols="30"></textarea>
          <input type="submit" value="Get In Touch" name="submit">

and my PHP code is -

<?php ini_set ("POP","mail.conceptcreativedesigns.co.uk");ini_set ("sendmail_from","info@conceptcreativedesigns.co.uk");
if(isset($_POST['submit'])) { 
$to = 'postmaster@conceptcreativedesigns.co.uk'; 
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset-ISO-8859-1\r\n";
$name_field = $_POST['name'];
$email_field = $_POST['email']; 
$message_field = $_POST['message']; 

$subject = 'New Message From - '.$name_field; 

$message = "<html><body>";
$message .= "<b>From:</b>&nbsp;&nbsp;&nbsp;".$name_field;
$message .= "<br><br><b>Email Address:</b>&nbsp;&nbsp;&nbsp;".$email_field;
$message .= "<br><br><b>Message:</b>&nbsp;&nbsp;&nbsp;".$message_field;
$message .="</body></html>";

echo '<script type="text/javascript"> 
window.onload=function(){alert("Thank you, your message has been sent.");} 
mail($to, $subject, $message, $headers); 
} else { 
echo "I'm sorry, your request had not been submitted. Please try again."; 

header("Location: contact_submit.html#thankyou");

I copied and pasted most of it and got it to where I need it, except for the 'required' bit.

Any suggestions as to what I can include and where to include it would really help!


6 Years
Discussion Span
Last Post by Gants

I dont understand what is your problem... all the time you will have a redirection to the header code... what is your problem ???


nice but better use regular expression.

Edited by Ezzaral: Snipped spam url.

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.