Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Why isn't my contact form PHP file working? [duplicate]

$
0
0

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");


}

?>

Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>