It's a very simple piece of code, but for some reason all I get is parse errors saying that the line that mail() is on has an unexpected string. Any ideas?
<?php
if (isset($_POST['submitted'])) {
// if form has been submitted, do this
$errors = array();
if (empty($_POST['name'])) {
$errors[] = 'You forgot to enter a name!';
}
if (empty($_POST['company'])) {
$errors[] = 'You forgot to enter a company!';
}
if (empty($_POST['email']) && !eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) {
$errors[] = 'You forgot to enter a (correct) email!';
}
if (empty($_POST['text'])){
$errors[] = 'You forgot to enter a message!';
}
if (empty($errors)){
$sendemail = 'drpimpervip@aol.com';
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$text = $_POST['text'];
$message = '
<html>
<body>
Someone new is asking a question!<p/>
Name: <b>'.$name.'</b><br/>
Company: <b>'.$company.'</b><br/>
Email: <b>'.$email.'</b><br/>
Message: <b>'.$text.'
</body>
</html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$result = @mail( $sendemail, New Contact at Communication Centers of Ohio, $message, $headers );
$result ? Message Sent : Message was not sent;
} else {
echo 'The Following Errors Occured:';
foreach ($errors as $msg) {
echo "-$msg<br />";
}
}
} else {
// display the form
echo '<form action="index.php" method="post">
<h2>Name</h2>
<input type="text" length="20" name="name" /><br />
<h2>Company</h2>
<input type="text" length="20" name="company" /><br />
<h2>Email</h2>
<input type="text" length="20" name="email" /><br />
<h2>Message</h2>
<textarea name="text" rows="10" cols="20">
Type your message here.
</textarea>
<input type="hidden" name="submitted" /><br />
<input type="submit" name="submit" title="Send the Message!" />
</form>';
}
?>