954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Form not working, getting parse errors...

Ok I have a form. You hit submit and it spits it back to you on a confirm page. You hit submit there and it is points you to the page with the following code that is supposed to email it to me.

<?

//Declare the variables
$recipient = "entries@mysite.com";
$subject = "Team Submission";
$message =
"$name
$teamname
$email
$tiebreaker
$team\";

//contents of form

$name = $_POST['name'];
$teamname= $_POST['teamname'];
$email = $_POST['email'];
$email = $_POST['tiebreaker'];
$team = $_POST['team'];
$headers = "Cc: $email\r\n;"

//mail() function sends the mail
mail($recipient,$subject,$message,$headers);

?>

I'm getting this error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site30/fst/var/www/html/submitted.php on line 21

Line 21 is $name = $_POST['name'];

Please help, I'm not THAT well versed in PHP but had this same damn form working last year and can't figure out where I'm putting or missing a ', ", or something else. :(

johnnybt
Newbie Poster
2 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

Ok I figured out that I had an extra \ in there, but then it's giving me this error on the mail function line:

Parse error: parse error, unexpected T_STRING in /home/virtual/site30/fst/var/www/html/submitted.php on line 31

johnnybt
Newbie Poster
2 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

[PHP]$message = "$name$teamname$email$tiebreaker$team\";[/PHP]

I think should be this:

[PHP]$message = "$name$teamname$email$tiebreaker$team";[/PHP]
or is that the first error you fixed?

Try echoing all your vars to the browser so you can see what they look like.
[PHP]
echo($_POST['name']);
echo($_POST['teamname']);
etc...
[/PHP]
My guess is one of the _POST vars is not defined which would mean there is a misspelling in your submission form.

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

[PHP]<?

//Declare the variables
$recipient = "entries@mysite.com";
$subject = "Team Submission";
$message =
"$name
$teamname
$email
$tiebreaker
$team\"; //there is no backslash on it.

//contents of form

$name = $_POST['name'];
$teamname= $_POST['teamname'];
$email = $_POST['email'];
$email = $_POST['tiebreaker'];
$team = $_POST['team'];
$headers = "Cc: $email\r\n;" //Error

//mail() function sends the mail
mail($recipient,$subject,$message,$headers);

?>[/PHP]

Should be like this.

[PHP]<?

//Declare the variables
$recipient = "entries@mysite.com";
$subject = "Team Submission";
$message =
"$name
$teamname
$email
$tiebreaker
$team";

//contents of form

$name = $_POST['name'];
$teamname= $_POST['teamname'];
$email = $_POST['email'];
$email = $_POST['tiebreaker'];
$team = $_POST['team'];
$headers = "Cc: $email\r\n";

//mail() function sends the mail
mail($recipient,$subject,$message,$headers);

?>[/PHP]

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You