Skip to main content
Inspiring
May 19, 2017
Answered

"MethodNotAllowedError" / "POST is not allowed" - PHP woes

  • May 19, 2017
  • 1 reply
  • 1368 views

Hey Dreamweaver geniuses--

I've recently completed my first attempt at a "contact us" form using PHP.  When I test the form and click "submit",  I get this:

{"code":"MethodNotAllowedError","message":"POST is not allowed"}

My form code and PHP code are below.  Would appreciate any advice.  Oh--and does the webpage with the form need to be a PHP file?  Or can it be an HTML file that simply contains a form with a PHP action?  

********************************************

FORM CODE

<div id="contactBox">

  <form action="mailscript.php" method="post" enctype="multipart/form-data" name="contactForm" id="contactForm" title="Contact Form">

     <p><em>*Required field </em></p>

     <p>

       <input name="firstname" type="text" required class="label" id="firstname" placeholder="First Name*">

      

       <input name="lastname" type="text" required class="label" id="lastname" placeholder="Last Name*">

      

       <input name="email" type="email" required class="label" id="email" placeholder="Email address*">

      

       <input name="phone" type="text" required class="label" id="phone" placeholder="Phone*" />

      

       <select name="timezone" class="selectItem" id="timezone" title="Time Zone">

         <option>Time Zone</option>

         <option>Pacific</option>

         <option>Mountain</option>

         <option>Central</option>

         <option>Eastern</option>

         <option>Other</option>

       </select>

      

       <select name="besttime" class="selectItem" id="besttime">

         <option>Best Time To Call</option>

         <option>Morning</option>

         <option>Midday</option>

         <option>Afternoon</option>

         <option>Evening</option>

       </select>

       <select name="referral" required class="selectItem" id="referral">

         <option>How did you hear about us?</option>

         <option>Option 1</option>

         <option>Option 2</option>

         <option>Someone referred me</option>

       </select>

      

     </p>

      <input name="submit" type="submit" class="submitButton" id="submit" form="contactForm" formaction="mailscript.php" formenctype="multipart/form-data" formmethod="POST" title="Submit" value="Submit">

    

   </form>

</div>

*************************************

CODE FOR "mailscript.php"

<?php

$from="noreply@domain.com";

$email="info@domain.com";

$subject="SUBMISSION";

$firstname=$_POST['firstname'];

$lastname=$_POST['lastname'];

$their_email=$_POST['email'];

$phone=$_POST['phone'];

$timezone=$_POST['timezone'];

$besttime=$_POST['besttime'];

$referral=$_POST['referral'];

mail ($email, $subject, "From:".$from)

?>

This topic has been closed for replies.
Correct answer BenPleysier
<form action="mailscript.php" method="post" enctype="multipart/form-data" name="contactForm" id="contactForm" title="Contact Form">

The highlighted value is required when you are using forms that have a file upload control

<input name="submit" type="submit" class="submitButton" id="submit" form="contactForm" formaction="mailscript.php" formenctype="multipart/form-data" formmethod="POST" title="Submit" value="Submit">

Not required.

If there is no PHP code inside a document, then there is no requirement for a PHP extension.

Now for the action script. Before I explain it all to you, please have a look at what Nancy has done to make the script secure Alt-Web Design & Publishing: Responsive Contact Form with Bootstrap 3.2 and PHP (Part 3)

She has included the action script in the document containing the form. This is not necessary, your method is equally correct.

1 reply

Inspiring
May 19, 2017

Update:

I switched the '$email' variable in the PHP file to "$to" ... and I am using a local server via MAMP Pro.

BenPleysier
Community Expert
BenPleysierCommunity ExpertCorrect answer
Community Expert
May 19, 2017
<form action="mailscript.php" method="post" enctype="multipart/form-data" name="contactForm" id="contactForm" title="Contact Form">

The highlighted value is required when you are using forms that have a file upload control

<input name="submit" type="submit" class="submitButton" id="submit" form="contactForm" formaction="mailscript.php" formenctype="multipart/form-data" formmethod="POST" title="Submit" value="Submit">

Not required.

If there is no PHP code inside a document, then there is no requirement for a PHP extension.

Now for the action script. Before I explain it all to you, please have a look at what Nancy has done to make the script secure Alt-Web Design & Publishing: Responsive Contact Form with Bootstrap 3.2 and PHP (Part 3)

She has included the action script in the document containing the form. This is not necessary, your method is equally correct.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!