{"code":"MethodNotAllowedError","message":"POST is not allowed"}
{"code":"MethodNotAllowedError","message":"POST is not allowed"}
This is the error I am getting. please, someone, help.
File:1 Form.php
<?php include('form_process.php'); ?>
<link rel="stylesheet" href="form.css" type="text/css">
<div class="container">
<form id="contact" action="<?= $_SERVER['PHP_SELF']; ?>" method="post">
<h3>Request a Free Business Analysis</h3>
<h4>Request a free 45 minute consultation
with a bookkeeping expert</h4>
<fieldset>
<input placeholder="Name" type="text" tabindex="1" name="Full Name" autofocus>
<span class="error"><?= $name_error ?></span>
</fieldset>
<fieldset>
<input placeholder="Email Address" type="text" name="Email" tabindex="2" >
<span class="error"><?= $name_error ?></span>
</fieldset>
<fieldset>
<input placeholder="Your Company" type="text" name="Your Company" tabindex="3" >
<span class="error"> <?= $name_error ?></span>
</fieldset>
<fieldset>
<input placeholder="Phone" type="text" name="Phone" tabindex="4" >
</fieldset>
<fieldset>
</fieldset>
<fieldset>
<button name="Request Consultation" type="submit" id="contact-submit" data-submit="...Sending">Request Consultation</button>
</fieldset>
<div class="Success"><?= $success; ?></div>
</form>
</div>
File 2: Form_process.php
<?php
// define variables and set to empty values
$name_error = $email_error = $name_error = $phone_error = "";
$name = $email = $name = $phone = $success = "";
//form is submitted with POST method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$name_error = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$email_error = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = "Invalid email format";
}
}
if (empty($_POST["name"])) {
$name_error = "Company name is required";
} else {
$name = test_input($_POST["Company name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$name_error = "Only letters and white space allowed";
}
}
if (empty($_POST["phone"])) {
$phone_error = "Phone is required";
} else {
$phone = test_input($_POST["phone"]);
// check if e-mail address is well-formed
if (!preg_match("/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i",$phone)) {
$phone_error = "Invalid phone number";
}
}
if ($name_error == '' and $email_error == '' and $name_error == '' and $phone_error == '' ){
$message_body = '';
unset($_POST['submit']);
foreach ($_POST as $key => $value){
$message_body .= "$key: $value\n";
}
$to = 'paulinpraveen@gmail.com';
$subject = 'Contact Form Submit';
if (mail($to, $subject, $message_body)){
$success = "Message sent, thank you for contacting us!";
$name = $email = $name = $phone = '';
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
File:3 Form.css
* {
margin:0;
padding:0;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-font-smoothing:antialiased;
-moz-font-smoothing:antialiased;
-o-font-smoothing:antialiased;
font-smoothing:antialiased;
text-rendering:optimizeLegibility;
}
.error {color: red;}
.success {color: #ff9966;
text-align: center;
font-weight: bold;
font-size: 14px;
}
body {
font-family: "Open Sans", Helvetica, Arial, sans-serif;
font-weight: 300;
font-size: 12px;
line-height: 30px;
color: #777;
background-color: transparent;
width: 430px;
height: 700px;
background-image: url(../images/Contact-form-background2.png);
background-repeat: no-repeat;
}
.container {
max-width:400px;
width:100%;
margin:0 auto;
position:relative;
}
#contact input[type="text"], #contact input[type="email"], #contact input[type="name"], #contact input[type="phone"], #contact textarea, #contact button[type="Request Consultation"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }
#contact {
background-color: transparent;
padding:25px;
margin:50px 0;
}
#contact h3 {
color: #F96;
display: block;
font-size: 30px;
font-weight: 400;
}
#contact h4 {
margin:5px 0 15px;
display:block;
font-size:13px;
}
fieldset {
border: medium none !important;
margin: 0 0 10px;
min-width: 100%;
padding: 0;
width: 100%;
}
#contact input[type="text"], #contact input[type="email"], #contact input[type="name"], #contact input[type="phone"], #contact textarea {
width:100%;
border:1px solid #CCC;
background:#FFF;
margin:0 0 5px;
padding:10px;
}
#contact input[type="text"]:hover, #contact input[type="email"]:hover, #contact input[type="name"]:hover, #contact input[type="phone"]:hover, #contact textarea:hover {
-webkit-transition:border-color 0.3s ease-in-out;
-moz-transition:border-color 0.3s ease-in-out;
transition:border-color 0.3s ease-in-out;
border:1px solid #AAA;
}
#contact textarea {
height:100px;
max-width:100%;
resize:none;
}
#contact button[type="submit"] {
cursor:pointer;
width:100%;
border:none;
background:#0CF;
color:#FFF;
margin:0 0 5px;
padding:10px;
font-size:25px;
}
#contact button[type="submit"]:hover {
background:#09C;
-webkit-transition:background 0.3s ease-in-out;
-moz-transition:background 0.3s ease-in-out;
transition:background-color 0.3s ease-in-out;
}
#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }
#contact input:focus, #contact textarea:focus {
outline:0;
border:1px solid #999;
}
::-webkit-input-placeholder {
color:#888;
}
:-moz-placeholder {
color:#888;
}
::-moz-placeholder {
color:#888;
}
:-ms-input-placeholder {
color:#888;
}
