0

I'm having some issue with my PHP. I'm new to it, so it's all kind of confusing. But the big issue is trying to send email thru a contact form and failing miserably.

I get this error:

Parse error: syntax error, unexpected '$name' (T_VARIABLE) in C:\wamp\www\mtltechevents\contact_form.php on line 7

Line 7:

$name = $_POST['name1'];

I can't see a syntax error. When I remove the error message, it echoes back when I try to fill in the info, as well:

$name = $_POST['name1'];
$email = $_POST['email1'];
$message = $_POST['message1'];
$contact = $_POST['contact1'];
$email = filter_var($email, FILTER_SANITIZE_EMAIL); // Sanitizing E-mail.
// After sanitization Validation is performed
if (filter_var($email1, FILTER_VALIDATE_EMAIL)) {
if (!preg_match("/^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*      (\d{4})(?: ​*x(\d+))?\s*​$/", $contact)) {
echo "<span>* Please Fill Valid Contact No. *</span>";

Any thoughts? I checked out some of the other issues with contact forms and none really answered what my problem was.

2 Answers2

0

Your error would usually show up if you are missing a semi-colon or bracket above the stated line as it is expecting you to do something else. An example of this would be

$anothervariable = $_POST['anotherpost'] // No semi-colon
$name = $_POST['name1'];
$email = $_POST['email1'];
$message = $_POST['message1'];
$contact = $_POST['contact1'];
Recnats
  • 377
  • 2
  • 13
0

Is session started?? Can you post complete code. It sounds like kind of syntax error

  • The error was actually more complex than that. But it was because I had used a php code to check for errors, I had placed it at the top of my code. – emilymacleod86 Jan 26 '16 at 18:44