[PROBLEM SOLVED] Email form
Posted: Thu Apr 13, 2006 8:07 am
I was just fooling about with an email form i made a while ago, and when i put it all neatly in a table i got this message:
Parse error: parse error, unexpected T_VARIABLE in /home/prexide/public_html/screwcork/contact.php on line 6
Probably some stupid mistake, but i cant find it.. :\
Code in full: (feel free to use it if you can make it work)
Any pointers?
Parse error: parse error, unexpected T_VARIABLE in /home/prexide/public_html/screwcork/contact.php on line 6
Probably some stupid mistake, but i cant find it.. :\
Code in full: (feel free to use it if you can make it work)
Code: Select all
<?php
if ($_POST['submit'] == TRUE) {
$receiverMail = "youremail@youremail.com"
$name = stripslashes(strip_tags($_POST['name']));
$email = stripslashes(strip_tags($_POST['email']));
$subject = stripslashes(strip_tags($_POST['subject']));
$msg = stripslashes(strip_tags($_POST['msg']));
$ip = $_SERVER['REMOTE_ADDR'];
$msgformat = "From: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo "<h2>Email was not sent.</h2><p>Please fill in all the fields!</p>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "<h2>Email was not sent.</h2><p>Email adress is not valid</p>";
}
elseif(mail($receiverMail, $subject, $msgformat, "From: $name <$email>")) {
echo "<h2>Your Email was sent.</h2><p>I will get back to you as soon as possible!</p>"; }
else {
echo "<h2>Email was not sent.</h2><p>Please try again! If the problem continues it might be a server error.</p>";
}
}
else { ?>
<form method="post" action="">
<table width="400" border="0" cellspacing="5" cellpadding="0">
<tr>
<th colspan="2" scope="row">
<label for="name">Name</label></th>
<td><input id="name" name="name" type="text" size="30" maxlength="40" /></td>
</tr>
<tr>
<th colspan="2" scope="row">
<label for="email">E-mail</label></th>
<td><input id="email" name="email" type="text" size="30" maxlength="40" /></td>
</tr>
<tr>
<th colspan="2" scope="row">
<label for="subject">Subject</label></th>
<td><input id="subject" name="subject" type="text" size="30" maxlength="40" /></td>
</tr>
<tr>
<th colspan="2" valign="top" scope="row">
<label for="message">Message</label></th>
<td><textarea id="message" name="msg" cols="40" rows="8"></textarea></td>
</tr>
<tr>
<th scope="row"><input id="submit" class="button" type="submit" name="submit" value="Send" /> </th>
<th scope="row"><input type="reset" name="Reset" value="Reset"></th>
<td> </td>
</tr>
</table>
</form>
<?php } ?>