Skip to main content
Known Participant
December 3, 2009
Question

My contact form is not working.

  • December 3, 2009
  • 3 replies
  • 2013 views

Here is my html code for my contact form which is located in Contact.htm :

<form method="POST" action="contact.php">

<p>Name:<br>

<input type="text" name="Name:">

<p>Company:<br>

<input type="text" name="Company:">

<p>Phone:<br>

<input type="text" name="Phone:">

<p>Email:<br>

<input type="text" name="Email:">

<p>Comments:<br>

  <textarea name="Comments:" cols="45" rows="5"></textarea>

<p><input type="submit" name="submit" value="Submit">

</form>

Here is my code which is located in my php file contact.php :

<?php

mb_http_input("UTF-8");

mb_http_output("UTF-8");

$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));

$EmailTo = "cproett805@gmail.com";

$Subject = "Web Contact Form";

$Name: = Trim(stripslashes($_POST['Name:']));

$Company: = Trim(stripslashes($_POST['Company:']));

$Phone: = Trim(stripslashes($_POST['Phone:']));

$Email: = Trim(stripslashes($_POST['Email:']));

$Comments: = Trim(stripslashes($_POST['Comments:']));

$validationOK=true;

if (Trim($EmailFrom)=="") $validationOK=false;

if (!$validationOK) {

  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

  exit;

}

$Body = "";

$Body .= "Name:: ";

$Body .= $Name:;

$Body .= "\n";

$Body .= "Company:: ";

$Body .= $Company:;

$Body .= "\n";

$Body .= "Phone:: ";

$Body .= $Phone:;

$Body .= "\n";

$Body .= "Email:: ";

$Body .= $Email:;

$Body .= "\n";

$Body .= "Comments:: ";

$Body .= $Comments:;

$Body .= "\n";

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

if ($success){

  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";

}

else{

  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

}

?>

------------------------------------------------------------

The error I get when I submit the information on the form is:

Parse error: syntax error, unexpected ':' in D:\Hosting\5199406\html\contact.php on line 8

Line 8 = $Name: = Trim(stripslashes($_POST['Name:']));

I actually took this line out to see if it would work and then it gave me an error that Line 9 was not working...

HELP PLEASE!

This topic has been closed for replies.

3 replies

Waleed Barakat
Known Participant
December 8, 2009

Hello,

Please try to read this tutorial hoping it may help

Creating a Contact form in Dreamweaver from scratch
In this tutorial we will build a contact form with Dreamweaver CS3 from scratch, our application consists of 2 pages, The first page contains the contact form, and the second page contains the form submission action and the thank you message. Also we will use Dreamweaver form validation behavior to validate the form. The Validate Form behavior checks the contents of specified text fields to ensure that the user has entered the correct type of data.

__
Best Regards
Waleed Barakat
Developer-Online Creator and programmer

Waleed Barakat
Known Participant
December 9, 2009

Hi, Please try to check the latest updates if you gonna to use this form.

Read this topic:

http://forums.adobe.com/message/2448862#2448862

clear code quest
Inspiring
December 5, 2009

Hi,

This seems to be a contact form from the contact form generator. You could easily generate a new form and refrain from modifying it afterwards.

Participating Frequently
December 3, 2009

Read the error message - it's telling you exactly what's wrong:

Parse error: syntax error, unexpected ':' in D:\Hosting\5199406\html\contact.php on line 8

You have an illegal character in your variable name. Change $Name: to $Name

Known Participant
December 3, 2009

okay, so i took the ":" out.

Now I when I hit the Submit button it try to go to error.htm page, which I have not yet created. But for it to go to that page would mean it is not validating correct?

So how do I fix this problem now?

Participating Frequently
December 3, 2009

You are validating a variable EmailFrom:

if (Trim($EmailFrom)=="") $validationOK=false;

This variable is populated from the form field that doesn't exist:

$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));

The form field you probably want to populate the variable from is Email:.