Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

My contact form is not working.

New Here ,
Dec 02, 2009 Dec 02, 2009

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!

TOPICS
Server side applications
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2009 Dec 02, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2009 Dec 02, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2009 Dec 03, 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:.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 04, 2009 Dec 04, 2009

Sorry I am not understanding. Do i need to replace the script that has $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); ?????

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 04, 2009 Dec 04, 2009

Your form contains this field:

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

Your php script defines these two variables:

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

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

There is no EmailFrom field defined in your form so you are trying to populate a variable from a non existent form field.  And the EmailFrom variable is the one you are then validating here:

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

So it will always be false. Get it? So you need get rid of line 1 above, fix line 2 so there is no colon in the variable name, and then change the variable that is being validated in line 3.

Also, I don't really know php so I can't say for sure, but that form script doesn't like very secure as there is no input validation. Check with one of the php gurus.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2009 Dec 05, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 08, 2009 Dec 08, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 09, 2009 Dec 09, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines