Page 1 of 1

[PROBLEM SOLVED] Email form

Posted: Thu Apr 13, 2006 8:07 am
by screwcork
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)

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>&nbsp;</td>
                    </tr>
                  </table> 
				</form>
<?php } ?>
Any pointers?

Re: Email form

Posted: Thu Apr 13, 2006 8:10 am
by timvw
screwcork wrote: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
So you have an error on line 6. (A syntax error).
Look carefully (and see that the ; is missing).

If looking carefully doesn't work for you consider getting an editor that is capable of code highlighting.
This makes most syntax errors easier to spot.

Re: Email form

Posted: Thu Apr 13, 2006 8:17 am
by screwcork
timvw wrote: Look carefully (and see that the ; is missing).
Well that was quite embarrasing *blush*

Thanx alot tho :)