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 = "me@yahoo.com";
      $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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.