Contact Form Trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cbaskauskas
Forum Newbie
Posts: 2
Joined: Fri Apr 30, 2010 12:34 pm

Contact Form Trouble

Post by cbaskauskas »

Hello, I am trying to get a contact form to work (http://businesscalcium.com/contact.html) but when the form submits I get an error "Parse error: syntax error, unexpected T_STRING in /var/www/web3/web/contactengine.php on line 42"

Here's the code for contactengine.php:

Code: Select all

<?php

// CHANGE THE THREE VARIABLES BELOW

$EmailFrom = "***email removed***";
$EmailTo = "***email removed***";

$Name = Trim(stripslashes($_POST['name']));
$Email = Trim(stripslashes($_POST['email']));
$Company = Trim(stripslashes($_POST['company']));
$Phone = Trim(stripslashes($_POST['phone']));
$Subject = Trim(stripslashes($_POST['subject'])); 
$Message = Trim(stripslashes($_POST['message'])); 

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

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

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
if ($success){
  print "<meta http-equiv="refresh" content="0;URL=contactthanks.html">";
}
else{
  print "<meta http-equiv="refresh" content="0;URL=error.html">";
}
?>
Anybody know what's causing the syntax error?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Contact Form Trouble

Post by mikosiko »

check your " usage in this lines... they are wrong

Code: Select all

  print "<meta http-equiv="refresh" content="0;URL=contactthanks.html">";
}
else{
  print "<meta http-equiv="refresh" content="0;URL=error.html">";
}
cbaskauskas
Forum Newbie
Posts: 2
Joined: Fri Apr 30, 2010 12:34 pm

Re: Contact Form Trouble

Post by cbaskauskas »

hmm i'm not very experienced with php. do i need to insert some slashes into those lines?
geoffmuskett
Forum Newbie
Posts: 22
Joined: Sat Feb 27, 2010 3:09 pm

Re: Contact Form Trouble

Post by geoffmuskett »

\ escapes characters that php might interpret like " and ;
Post Reply