ebryant77 Posted April 9, 2010 Share Posted April 9, 2010 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\">"; } ?> Link to comment https://forums.phpfreaks.com/topic/198173-submit-not-working-returns-php-code-when-clicked-please-help/ Share on other sites More sharing options...
JAY6390 Posted April 9, 2010 Share Posted April 9, 2010 Are you sure that you have a php compatible server with it enabled? That's the only reason I can think of that this wouldn't work Link to comment https://forums.phpfreaks.com/topic/198173-submit-not-working-returns-php-code-when-clicked-please-help/#findComment-1039798 Share on other sites More sharing options...
ebryant77 Posted April 9, 2010 Author Share Posted April 9, 2010 Thank you Jay...will have to check with IT on that...I appreciate the input! That would make sense to me! Link to comment https://forums.phpfreaks.com/topic/198173-submit-not-working-returns-php-code-when-clicked-please-help/#findComment-1039811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.