Page 1 of 1

email contact form

Posted: Tue Sep 23, 2008 1:27 pm
by consolestrat
everything works in this code except the $video. everything shows up except that field in the email. please help!

<html>
<head><title>Consolestrat.com Video Input</title>
</head>
<body bgcolor="black">
<font color="white">

<?php
//This code runs if the form has been submitted
if (array_key_exists('submit', $_POST))
{

// check fields are not empty
$name = trim($_POST['name']);
if (strlen($name) < 3) {
$error['name'] = 'Name Must be more then 3 characters.';
}
if (strlen($name) > 20) {
$error['name'] = 'Name Must be less then 20 characters.';
}

// check for valid email address
$email = $_POST['email'];
$pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
$error[] = 'Please enter a valid email address';
}

// check fields are not empty
$message = trim($_POST['message']);
if (strlen($message) < 10) {
$error['message'] = 'Description must be more than 10 characters.';
}

// if validation is okay then carry on
if (!$error ) {

//send email
$to = "videos@consolestrat.com";
$subject = "Video Submission from $name";
$body = "on ".date('M j, Y')."Name: $name | Email:$email | Video URL:$video | Description: $message";
$additionalheaders = "From: <$email> ";
$additionalheaders .= "Replt-To: $email";
if(mail($to, $subject, $body, $additionalheaders))
{
$sent = true;
}

} // end validation
}// end submit


// If mail is sent
if (isset($sent)) {

echo "<p>Thank you!</p>";
echo "<p>We will post your video as soon as possible! Please allow a few days for your submission to be processed.</font> </p>";


} else { // mail not sent show form

echo "<p>Help our site grow, submit a video!</p>";
echo "<p>I hate spam and I'm sure you do too, so don't worry your email address will <strong>NOT</strong> be passed on to any third party's </p>";

// show any errors if set
echo "<blockquote>";
if (isset($error['name'])) {
echo "<p><span class=\"warning\">".$error['name']."</span></p> ";
}
if (isset($error['email'])) {
echo "<p><span class=\"warning\">".$error['email']."</span></p> ";
}
if (isset($error['video'])) {
echo "<p><span class=\"warning\">".$error['video']."</span></p> ";
}
if (isset($error['message'])) {
echo "<p><span class=\"warning\">".$error['message']."</span></p> ";
}
echo "</blockquote>";
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset width="500">
<legend>Contact</legend>
<p><label>Name:</label> <input name="name" type="text" maxlength="20" <?php if(isset($error)) {echo "value='$name'";} ?> /></p>

<p><label> Email:</label>
<input name="email" type="text" maxlength="1000" <?php if(isset($error)) {echo "value='$email'";} ?> /></p>
<p><label> Video URL:</label>
<input name="video" type="text" maxlength="50" <?php if(isset($error)) {echo "value='$video'";} ?> /></p>

<p><label>Message:</label>
<textarea name="message" cols="50" rows="10" id="message"><?php if(isset($error)) {echo $message;} ?></textarea>
</p>

<p><input type="submit" name="submit" value="Send Message"></p>
</fieldset>
</form>
<?php } ?>

<p><a href='http://www.youtube.com'>YOUTUBE.COM</a> | <a href='http://www.metacafe.com'>METACAFE.COM</a></p>
</body>
</html>