-2

I don't know much PHP but I used a tutorial to connect my contact form to my email. Below is my html contact form, and the PHP file I wrote:

<form name="contactform" method="post" action="mail.php">

 <label for="fname">Name</label>
 <input type="text" id="fname" name="name" placeholder="Your name..">


 <label for="email">Email</label>
 <input type="text" id="email" name="email" placeholder="Your email address">

 <label for="city">City</label>
 <input type="text" id="city" name="city" placeholder="Your city">

 <label for="message">Message</label> 
 <textarea id="message" name="message" placeholder="Write something.." style="height:170px"> 
 </textarea>

 <input type="submit" value="Submit" name="submit">
</form>

<?php

if (isset($_POST['submit'])){
$name = $_POST['name']; 
$mailFrom= $_POST['email']; 
$city = $_POST['city']; 
$message = $_POST['message'];  

$mailTo = "(insert my email here)";
$headers = "From: ".$mailFrom;
$txt = "You received an e-mail from ".$name.".\n\n"

mail($mailTo, $txt, $headers);
header("Location: " contact.html?mailsend");


}

?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Ben
  • 1
  • 3
    Looks like a parse error in your PHP. `header("Location: " contact.html?mailsend");1` There's an extra quote in the middle there – Don't Panic Feb 20 '20 at 23:29

1 Answers1

-3
if (isset($_POST['submit']))

that will never be true, change it to any other field. name,email, city, message

ATechGuy
  • 1,240
  • 8
  • 13