Double-check a contact form
I borrowed this form from a previous website I "frankensteined" - my friend helped me with this script.... I was hoping to use it again for this website http://richieadams.com (click on contact)
Does all the documentation look correct, will this form work?
HTML Code:
<div id="contactFormContainer" class="clearfix">
<form action="email.php" method="POST" class="form" id="contactForm">
<span class="hidden isSubmitted">Submitted</span>
<label for="name">Name</label>
<input type="text" id="name" name="name" class="validate[required,custom[onlyLetterSp],maxSize[30]] text-input" />
<label for="email">Email</label>
<input type="email" id="email" name="email" class="validate[required,custom[email]] text-input" />
<label for="subject">Subject</label>
<input type="text" id="subject" name="subject" class="validate[required,custom[onlyLetterSp],maxSize[40]] text-input" />
<label for="message">Messsage</label>
<textarea name=message id=message class="validate[required] text-input"></textarea><br />
<input type="submit" value="Submit" name="submit" class="submit">
<input type="reset" value="Clear" name="clear" class="submit">
</form>
</div>
PHP Code:
<?php
require_once 'lib/swift_required.php';
// Set who is going to get the email
$to = 'info@rrc.la';
// Set the subject. This is being pulled from posted form
$subject = $_POST['subject'];
$from = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$date = date("F j, Y, g:i a", strtotime('2 hours'));
$message = Swift_Message::newInstance()
->setSubject('RRC.LA Contact Form: ' . $subject)
//Set the From address with an associative array
->setFrom(array($from => $name))
//Set the To addresses with an associative array
->setTo(array($to))
//Give it a body
->setBody("Subject: $subject \n From: $name \n Message: $message \n\n timestamp: $date")
//And optionally an alternative body
->addPart("<h3>RRC.LA Contact Form</h3><b>Subject:</b> $subject <br /><br /> <b>From:</b> $name <br /><br /> <b>Message:</b> $message <br /><br /><br /><i>timestamp: $date", 'text/html')
;
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'contact.html#submitted';
header("Location: http://$host$uri/$extra");