Skip to main content
Participant
June 15, 2018
Answered

I need help with Mail send

i am coding a website for my school project and it was working fine until i tried to code a working contact page, everytime i try to check if my contact page works it brings up this

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

here is my code

<!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

<link rel="stylesheet" type="text/css" href="Untitled-2.css">

<link href="https://fonts.googleapis.com/css?family=Quicksand:500" rel="stylesheet">

<div class="header">

<h1>Contact Us!</h1>

<p>

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

</p>

</div>

<div class="contact-form">

<form id="contact-form" method="post" action="contact-form-yeeet.php">

<input name="name" type="text" class="form-control" placeholder="Name" Required>

<br>

<input name="email" type="email" class="form-control" placeholder="E-Mail">

<br>

<textarea name="message" class="form-control" placeholder="Message" row="4" required></textarea>

<br>

<input type="submit" class="form-control submit" value="SEND MESSAGE">

</form>

</div>

</html>

@charset "UTF-8";

/* CSS Document */

html, body {

width: 100%;

height: 100%;

padding: 0;

margin: 0px;

}

body {

margin: 0;

padding: 0;

font-family: Quicksand;

}

nav {

position: fixed;

top: 0;

left: 0;

width: 100%;

height: 100px;

padding: 10px 100px;

box-sizing: border-box;

transition: .3s;

}

nav.black {

background: rgba(0,0,0,0.8);

height: 100px;

padding: 10px 100px;

}

nav.logo {

padding: 22px 20px;

height: 80px;

float: left;

font-size: 24px;

transition: .3s;

}

nav.black .logo {

color: #fff;

}

nav ul {

list-style: none;

float: right;

margin: 0;

padding: 0;

display: flex;

}

nav ul li {

list-style: none;

}

nav ul li a {

line-height: 80px;

color: #151515;

padding: 12px 30px;

text-decoration: none;

text-transform: uppercase;

transition: .3s;

}

nav.black ul li a {

color: #fff;

}

nav ul li a:focus {

outline: none;

}

nav ul li a.active {

background: #E2472F;

color: #fff;

border-radius: 6px;

}

section.sec1 {

width: 100%;

height: 60vh;

background: url(../BG.jpg);

background-size: cover;

background-position: center;

}

.content {

margin-top: 60px;

}

.content p {

width: 900px;

margin: 30px auto;

text-align: justify;

font-size: 20px;

line-height: 30px;

}

slider {

display: block;

width: 100%;

height: 60%;

background-color: #1f1f1f;

overflow: hidden;

position: absolute;

}

slider >* {

position: absolute;

display: block;

width: 100%;

height: 100%;

background: #1f1f1f;

animation: slide 12s infinite;

overflow: hidden;

}

slide:nth-child(1) {

left: 0%;

animation-delay: -1s;

background-image: url(../../Slider/1.png);

background-size: cover;

background-position: center;

}

slide:nth-child(2) {

animation-delay: 2s;

background-image: url(../../Slider/2.png);

background-size: cover;

background-position: center;

}

slide:nth-child(3) {

animation-delay: 5s;

background-image: url(../../Slider/3.png);

background-size: cover;

background-position: center;

}

slide:nth-child(4) {

left: 0%;

animation-delay: 8s;

background-image: url(../../Slider/4.png);

background-size: cover;

background-position: center;

}

slide p {

font-family: Comfortaa;

font-size: 0px;

text-align: center;

display: inline-block;

width: 100%;

margin-top: 340px;

color: #fff;

}

@14668356 slide {

0% { left: 100%; width: 100%;}

5% { left: 0%;}

25% { left: 0%;}

30% { left: -100%; width: 100%;}

30.0001% { left: -100%; width: 0%;}

100% { left: 100%; width: 0%;}

}

.header {

text-align: center;

position: absolute;

top: 30%;

left: 50%;

transform: translate(-50%, -50%);

}

.header h1 {

color: #151515;

font-size: 46px;

}

.header p {

color: #151515;

font-size: 12px;

}

.contact-form {

position: absolute;

top: 60%;

left: 50%;

transform: translate(-50%, -50%);

text-align: center;

}

input {

width: 100%;

margin: 20px 0;

background: rgba(0,0,0,0);

border: none;

border-bottom: 1px solid #0078ff;

}

#msg {

margin-top: 60px;

}

::-webkit-input-placeholder {

color: #EAEAEA;

font-size: 12px;

letter-spacing: 2px;

}

button {

padding: 20px 32px;

font-size: 16px;

background: #0078ff;

border: none;

border-radius: 4px;

margin-top: 40px;

color: #fff;

}

form .submit {

background-color: #0078ff;

}

input {

height: 45px;

}

.form-control {

width: 600px;

background: transparent;

border: none;

outline: none;

border-bottom: 1px solid;

color: #000000;

font-size: 18px;

}

<?php

     $name = $_POST['name'];

$visitor_email = $_POST['email'];

    $message = $_POST['message'];

$email_from = 'parkplayz@gmail.com';

$email_subject = "New Form Submission";

$email_body = "User Name: $name.\n".

"User Email:  $visitor_email.\n".

"User Message: $message.\n";

$to = "cluelessxdd@gmail.com";

$headers = "From: $email_from \r\n";

$headers .= "Reply-To: $visitor_email \r\n";

mail($to,$email_subject,$email_body,$headers);

header("Location: home.html");

?>

This topic is closed to new replies. Start a new post to keep the conversation going.
osgood_Correct answer
Legend
June 15, 2018

Are you testing the form on a remote server or just trying to process the form locally (on your computer)?

If you are tyring to process the form locally you will need a local server set up to parse php files.

3 replies

WolfShade
Legend
June 15, 2018

To add to what osgood_ and Nancy have provided, you should not use reserved words as name or ID of an element:

<input name="name" type="text" class="form-control" placeholder="Name" Required>

Should be something like (or use something similar):

<input name="username" type="text" class="form-control" placeholder="Name" Required>

Especially if you are using Javascript to validate (use server-side, too!) or get/set/change anything like attributes or values.

V/r,

^ _ ^

Translate
osgood_Correct answer
Legend
June 15, 2018

Are you testing the form on a remote server or just trying to process the form locally (on your computer)?

If you are tyring to process the form locally you will need a local server set up to parse php files.

Translate
Nancy OShea
Community Expert
Community Expert
June 15, 2018

My local testing server (Wamp) doesn't send mail.  It's not configured for it.   I always test forms / scripts on the remote server where the site will be hosted to ensure everything works.

Translate
Nancy O'Shea— Product User & Community Expert