Jump to content

Getting an error when submitting a form with the mail() function


Wolverine68

Recommended Posts

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>

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.