Hi all,

I'm hoping I can find some help with this form ...

Upon submission, it's giving me a: Parse error: syntax error, unexpected T_STRING in .../contactengine.php on line 9

I have tried editing the form as well as checking for any missing semi colons, etc, but to no avail. Any help would be greatly appreciated ~

Forms code is below:

<?php

$EmailFrom = "";
$EmailTo = "";
$Subject = "";
$Injury = Trim(stripslashes($_POST['Injury'])); 
$Explain = Trim(stripslashes($_POST['Explain'])); 
$Date = Trim(stripslashes($_POST['Date'])); 
$Injured = Trim(stripslashes($_POST['Injured'])); 
$Are You Currently Represented = Trim(stripslashes($_POST['Are You Currently Represented'])); 
$Additional Comments = Trim(stripslashes($_POST['Additional Comments'])); 
$Name = Trim(stripslashes($_POST['Name'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Street Address = Trim(stripslashes($_POST['Street Address'])); 
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Zip = Trim(stripslashes($_POST['Zip']));   
$Home = Trim(stripslashes($_POST['Home'])); 
$Work = Trim(stripslashes($_POST['Work'])); 
$Other = Trim(stripslashes($_POST['Other'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Injury: ";
$Body .= $Injury;
$Body .= "\n";
$Body .= "Explain: ";
$Body .= $Explain;
$Body .= "\n";
$Body .= "Date: ";
$Body .= $Date;
$Body .= "\n";
$Body .= "Injured Party: ";
$Body .= $Injured Party;
$Body .= "\n";
$Body .= "Are You Currently Represented: ";
$Body .= $Are You Currently Represented;
$Body .= "\n";
$Body .= "Additional Comments: ";
$Body .= $Additional Comments;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Street Address: ";
$Body .= $Street Address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $Zip;
$Body .= "\n";
$Body .= "Home: ";
$Body .= $Home;
$Body .= "\n";
$Body .= "Work: ";
$Body .= $Work;
$Body .= "\n";
$Body .= "Other: ";
$Body .= $Other;



// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Thanks so much.

  • Ahhh ... wondering if I'm answering my own question here, but am I right to assume that fields like this one: $Are You Currently Represented - error may be due to the spaces between those words? Jennifer almost 7 years ago
  • that's what I was going to suggest you look at :) danwellman almost 7 years ago

1 answer

2
points

You can't use spaces in PHP variable names. And you shouldn't use spaces in your form element names either. Use '_' (underscore) in place of spaces.

$Are_You_Currently_Represented = Trim(stripslashes($_POST['Are_You_Currently_Represented']));
Answered almost 7 years ago by Gary Hepting
  • Yea, "$Are You.." will indicate "$Are" is the variable name and "You" will break the code because it is not a valid syntax/keyword. o.k.w almost 7 years ago