Jump to content

Submit not working - returns php code when clicked - Please help!


ebryant77

Recommended Posts

When I test this form, instead of sending the info or returning the 'thank you' or 'error' messages, the php code connected to the form is displayed in the browser window.

Why is this happening and how can I fix it?

Any help is greatly appreciated!!

Thanks in advance....

Here is the code:

HTML:

<form action="contact_freeoffer.php" method="post" enctype="multipart/form-data" name="freeoffer" id="freeoffer">

                  <em>Fields marked (*) are required

                  </em>                 

                  <table width="601" cellpadding="5">

                    <tr>

                      <td width="178" align="right">Company:* </td>

                      <td width="395"><input name="Company" type="text" size="45" /></td>

                    </tr>

                    <tr>

                      <td align="right">Contact Name:* </td>

                      <td><input name="ContactName" type="text" size="45" /></td>

                    </tr>

                    <tr>

                      <td align="right">Title:</td>

                      <td><input name="Title" type="text" size="45" /></td>

                    </tr>

                    <tr>

                      <td align="right">Email:* </td>

                      <td><input name="Email" type="text" size="45" /></td>

                    </tr>

                    <tr>

                      <td align="right">Phone:</td>

                      <td><input type="text" name="Phone" /></td>

                    </tr>

                    <tr>

                      <td align="right">Select an image to upload:</td>

                      <td><input type="file" name="Image" id="Image" /></td>

                    </tr>

                    <tr>

                      <td align="right">Notes:</td>

                      <td><textarea name="Notes" cols="45" rows="5"></textarea></td>

                    </tr>

                    <tr>

                      <td colspan="2" align="center"><input type="submit" name="submit" value="Submit" /></td>

                    </tr>

                  </table>

                  <p> </p>

                </form>

               


<?php

$EmailTo = "[email protected]";
$Subject = "Prospective Client: Free Offer Request";
$Company = $_POST['Company']; 
$ContactName = $_POST['ContactName']; 
$Phone = $_POST['Phone']; 
$Email = $_POST['Email']; 
$Title = $_POST['Title']; 
$Image = $_POST['Image']; 
$Notes = $_POST['Notes']; 


$validationOK=true;
if ($EmailFrom=="") $validationOK=false;
if ($Company=="") $validationOK=false;
if ($ContactName=="") $validationOK=false;
if ($Email=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
  exit;
}

$Body = "";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "ContactName: ";
$Body .= $ContactName;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Notes: ";
$Body .= $Notes;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.