Making a contact form work

Making a contact form work


Hi all. I am just about to finish a project i have been working on, but i would like the contact form to work. It needs to send the information a user has asked me to my email address. Please help me.

<form method="post" name="[email protected]" action="form-to-email.php">
    <div class="conatct-container">
    <h2>Contact Me Now!</h2>
    <input type="name"
           placeholder="Your name">
    <input type="email"
           placeholder="E-mail address">
    <textarea class="message"
              placeholder="Type your message here..."></textarea>
    <input type="submit"


		$to='[email protected]';
		$subject='Form Submission';
		$message="Name :".$name."\n"."\n"."Wrote the following :"."\n\n".$message;
		$headers="From: ".$email;

		if(mail($to, $subject, $message, $headers)){
			echo "<h1>Sent Successfully! Thank you"." ".$name.", I will contact you shortly!</h1>";
			echo "Something went wrong!";


You have many issues with your code. To access an input’s value, the input must have a name attribute of the same name you reference in the php POST request. For example, you reference an input by the name of ‘submit’ in the php file ($_POST[‘submit’], but you do not have a name attribute of submit for the Submit button.

In the above php line, you reference a variable named $message (at the end), but $message has not been defined anywhere before this line.

The same problem exists for the following line.

if(mail($to, $subject, $message, $headers)){

FYI - You should give your form’s name attribute a value which describes what the form is instead of an email address. For example, name=“contact-form”.