mandogovie Posted November 23, 2009 Share Posted November 23, 2009 Hi, I created an e-mail contact form on my website and have also created a PHP script to handle mailing. However, when I click on the submit button of my form so that the script will send the e-mail, it downloads the .php file instead of using it. The form on the HTML document looks like this: <table> <form method="post" action="mailform.php"> <tr> <td class="formtext">Name: </td> <td class="contactbox"><input type="text" name="name" maxlength="50" /></td> </tr> <tr> <td class="formtext">E-mail: </td> <td class="contactbox"><input type="text" name="email" maxlength="60" /></td> </tr> <tr> <td class="formtext">Subject: </td> <td class="contactbox"> <select name="subject" size="1"> <option value="opt1">Option 1</option> <option value="opt2">Option 2</option> <option value="opt3">Option 3</option> <option value="Webmaster Services">Webmaster Services</option> <option value="Search Engine Optimization"> Search Engine Optimization</option> </select></td></tr> <tr> <td class="formtext" valign="top">Message: </td> <td class="contactbox"><textarea name="message" rows="5" cols="35px"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" value="Send" /> <input type="reset" value="Clear" /></td> </colgroup> </form> </table> The mailform.php file looks like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>E-mail Form</title> </head> <body> <?php $to = "[email protected]"; $headers='From: $email'; if (mail($to, $subject, $message, $email, $headers)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> </body> </html> Thank you for any help, I can't find the error. Link to comment https://forums.phpfreaks.com/topic/182706-mail-script/ Share on other sites More sharing options...
Goldeneye Posted November 23, 2009 Share Posted November 23, 2009 First off, $subject, $message, and $email are undefined. It might help to define them. Either this line: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> is the culprit or the server you're using does not support PHP. At least, that's what it sounds like. Link to comment https://forums.phpfreaks.com/topic/182706-mail-script/#findComment-964336 Share on other sites More sharing options...
mandogovie Posted November 23, 2009 Author Share Posted November 23, 2009 I apologize, I have tried it also with the variables instantiated like this and it still downloads the script file instead of using it: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <title>E-mail Form</title> </head> <body> <?php $to = "[email protected]"; $subject = $_REQUEST["subject"]; $message = $_REQUEST["message"]; $email = $_REQUEST["email"]; $headers='From: $email'; if (mail($to, $subject, $message, $email, $headers)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/182706-mail-script/#findComment-964347 Share on other sites More sharing options...
Goldeneye Posted November 24, 2009 Share Posted November 24, 2009 Do you have other PHP scripts on your server that end up getting downloaded instead of executed or is this the only script that does? Link to comment https://forums.phpfreaks.com/topic/182706-mail-script/#findComment-964434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.