Page 1 of 1

PHP Form woe!!!

Posted: Sat Feb 13, 2010 2:59 am
by twethereld
Hi, I'm, having trouble with a PHP contact form that I created, and I've been searching the net high and low for a solution to no avail.

I've got my contact.html file, with a form in it (the code is below)

Code: Select all

<form action="ContactEmail.php" method="post" name="form1" id="form1" onsubmit="MM_validateForm('Name',''… document.MM_returnValue">
      <table width="389" border="0" cellspacing="1" cellpadding="1">
        <tr>
          <td width="110" align="right" valign="middle"><span class="style2">Name: </span></td>
          <td width="272"><input name="Name" type="text" id="Name" size="25" /></td>
        </tr>
        <tr>
          <td align="right" valign="middle"><span class="style2">Phone: </span></td>
          <td><input name="Phone" type="text" id="Phone" size="25" /></td>
        </tr>
        <tr>
          <td align="right" valign="middle"><span class="style2">Email: </span></td>
          <td><input name="Email" type="text" id="Email" onblur="MM_validateForm('firstname','','… document.MM_returnValue" size="25" /></td>
        </tr>
        <tr>
          <td align="right" valign="middle"><span class="style2">Project Location: </span></td>
          <td><input name="Location" type="text" id="Location" size="25" /></td>
        </tr>
        <tr>
          <td align="right" valign="top"><span class="style2">Project Description: </span></td>
          <td><textarea name="Description" cols="30" rows="7" id="Description"></textarea></td>
        </tr>
        <tr>
          <td align="right" valign="top"><span class="style2">Enquiry:</span></td>
          <td><textarea name="Enquiry" cols="30" rows="7" id="Enquiry"></textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="clear" type="reset" id="clear" value="Clear Form" />
            <input type="submit" name="Submit" value="Submit" /></td>
        </tr>
      </table>
      </form>
and my ContactEmail.php script is here:

Code: Select all

<?php
 
$Name = $_POST["Name"];
$Phone = $_POST["Phone"];
$Email = $_POST["Email"];
$Location = $_POST["Location"];
$Description = $_POST["Description"];
$Enquiry = $_POST["Enquiry"];
 
$ToEmail = "myemail@myemail.com";
$ToSubject = "Website Inquiry";
 
$EmailHeader="An enquiry via the website\n\n\n";
$EmailBody = "Name: $name\nPhone: $phone\nEmail: $email\nProject Location: $Location\nProject Description: $Description\nEnquiry: $enquiry\n";
 
$Message = $EmailHeader.$EmailBody;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");
?>
 
I've been tearing my hair out with this one. I can't seem to get anything but an error page. My website has PHP 5.2.12 installed.

If anyone can see where I'm going wrong, I would appreciate the help very much. I'm literally pulling my hair out.

Thanks.

Tess :banghead:

Re: PHP Form woe!!!

Posted: Sat Feb 13, 2010 5:23 am
by flying_circus
I have not even bothered to look through your code at this point. You havent told us what error you are receiving.

Re: PHP Form woe!!!

Posted: Sat Feb 13, 2010 5:28 am
by social_experiment

Code: Select all

<php mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">"); ?>
You don't specifiy the error you are receiving, but try equating the variables before sending the mail :

Code: Select all

<?php $to = "$ToName <$ToEmail>";
                $ToSubject = "$subject";
                $Message = "$message";
                $headers = "From: $FirstName <$Email>";
       
        mail($to, $ToSubject, $Message, $headers);?>
Hope this helps.

Re: PHP Form woe!!!

Posted: Sat Feb 13, 2010 5:30 am
by twethereld
Sorry about that. This is the error message I receive:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@myemail.com.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Re: PHP Form woe!!!

Posted: Sat Feb 13, 2010 5:34 am
by social_experiment
I dont think that is an error due to your code. You should contact the server administrator and tell him about the problem.