Wolverine68 Posted May 7, 2011 Share Posted May 7, 2011 Created a simple html form. Upon submission, it's suppose to email the information entered in the form to the designated recipient. Instead, I get the error "The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. " -------------------------------------------------------------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Mail Function</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $recipient = "[email protected]"; $subject = "Registration Submission"; $body = "<h2>Registration Information:</h2>"; $body .= "\r\nName: ($_POST['name'])"; $body .= "\r\nEmail: ($_POST['email']"; $body .= "\r\nQuestion: ($_POST['question']"; if (mail($recipient, $subject, $body)) { print("Email successfully sent!"); } else { print("The email could not be sent."); } ?> <form method="post"> <h2 align="center">Week 2 Project--Sending Email</h2> <br /> <div> <p>Enter your name and email address, a question, and click "Submit":</p><br /> <p>Name:<input type="text" name="name" size="20"></p> <p>Email:<input type="text" name="email" size="20"></p> <p>Question:<input type="text" name="question" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/ Share on other sites More sharing options...
Zurev Posted May 7, 2011 Share Posted May 7, 2011 Change your form tag to be: <form action="" method="post"> And let us know if it persists. Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212023 Share on other sites More sharing options...
teddyb Posted May 7, 2011 Share Posted May 7, 2011 Your script sends a message when the form is first requested too? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212026 Share on other sites More sharing options...
Wolverine68 Posted May 7, 2011 Author Share Posted May 7, 2011 No, same error when adding "action=""" Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212030 Share on other sites More sharing options...
teddyb Posted May 7, 2011 Share Posted May 7, 2011 what about method="POST" youre using iis right? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212045 Share on other sites More sharing options...
Wolverine68 Posted May 7, 2011 Author Share Posted May 7, 2011 Are you saying I should be using "GET" instead? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212047 Share on other sites More sharing options...
teddyb Posted May 7, 2011 Share Posted May 7, 2011 no the word POST in capitals? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212048 Share on other sites More sharing options...
Wolverine68 Posted May 7, 2011 Author Share Posted May 7, 2011 Try putting "POST" in lower case? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212050 Share on other sites More sharing options...
Wolverine68 Posted May 7, 2011 Author Share Posted May 7, 2011 correction..."POST" in upper case, right? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212051 Share on other sites More sharing options...
teddyb Posted May 7, 2011 Share Posted May 7, 2011 yes! Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212052 Share on other sites More sharing options...
Wolverine68 Posted May 7, 2011 Author Share Posted May 7, 2011 Changed "POST" to upper case, but still get the same error. Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212054 Share on other sites More sharing options...
Wolverine68 Posted May 9, 2011 Author Share Posted May 9, 2011 Anybody have any other suggestions? Link to comment https://forums.phpfreaks.com/topic/235790-getting-an-error-when-submitting-a-form-with-the-mail-function/#findComment-1212964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.