PHP Form woe!!!

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
twethereld
Forum Newbie
Posts: 2
Joined: Sat Feb 13, 2010 2:53 am

PHP Form woe!!!

Post 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:
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: PHP Form woe!!!

Post 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.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Form woe!!!

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
twethereld
Forum Newbie
Posts: 2
Joined: Sat Feb 13, 2010 2:53 am

Re: PHP Form woe!!!

Post 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.
Last edited by twethereld on Sat Feb 13, 2010 5:35 am, edited 1 time in total.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Form woe!!!

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply