Hi, i amwanting to know ow i can make these three form fileds required. i want 'YourName', 'YourEmail' and 'YourMessage' to be required.
Below is contact_script.php file
Below is the form part of contact.php (dont know if you will need itPHP Code:<?php
// get posted data into local variables
$EmailFrom = "ryan.fitton@hotmail.co.uk";
$EmailTo = "ryan.fitton@hotmail.co.uk";
$Subject = "Email From Personal Website";
$YourName = Trim(stripslashes($_POST['YourName']));
$YourEmail = Trim(stripslashes($_POST['YourEmail']));
$YourMessage = Trim(stripslashes($_POST['YourMessage']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=contact_error.php\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "YourName: ";
$Body .= $YourName;
$Body .= "\n";
$Body .= "YourEmail: ";
$Body .= $YourEmail;
$Body .= "\n";
$Body .= "YourMessage: ";
$Body .= $YourMessage;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contact_sent.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=contact_error.php\">";
}
?>)
HTML Code:<form method="post" action="contact_script.php"> <p>Your Name:<br /> <input type="text" name="YourName" class="contact_text_Input" /> </p> <p>Your Email:<br /> <input type="text" name="YourEmail" class="contact_text_Input" /> </p> <p>Your Message:<br /> <textarea name="YourMessage" cols="" rows="" class="contact_textarea_Input"></textarea> </p> <p><input type='image' name='submit' src='images/send_button.gif' class='contact_submit_Input' /> </p> </form>



)
Reply With Quote

Bookmarks