0

Here i used two files contact_us.php & mail.php

its not gives any error but not getting mail, please help me any thing wrong in below code.

contact_us.php

<!DOCTYPE HTML>
<html>
<head>
  <title>TPC</title>
  <meta name="description" content="website description" />
  <meta name="keywords" content="website keywords, website keywords" />
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="style/style.css" title="style" />
</head>

<body>
<form action="mail.php" method="post">
Name: <input class="contact" type="text" name="your_name" value="" /><br><br>
Email Address: <input class="contact" type="text" name="your_email" value="" /><br><br>
Message: <textarea class="contact textarea" rows="8" cols="50" name="your_enquiry"></textarea><br><br>
<p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="submit" value="submit" /></p>
</form>
</body>
</html>

mail.php

<?php 
    if(isset($_POST['submit'], $_POST['name'], $_POST['email'], $_POST['message'], $_POST['recipient'], $_POST['subject'], $_POST['formcontent'], $_POST['mailheader'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "myid@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";

mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    };
echo "Thank You!";

?>
Sagar
  • 43
  • 13

1 Answers1

0

There are no fields with name: name, email, message and nothing like: $_POST['recipient'], $_POST['subject'], $_POST['formcontent'], $_POST['mailheader']

try code below or change the names of the fields in the form

        if(isset($_POST['submit'], $_POST['your_name'], $_POST['your_email'], $_POST['your_enquiry'])) {
    $name = $_POST['your_name'];
    $email = $_POST['your_email'];
    $message = $_POST['your_enquiry'];

/* rest whatever you are trying to do*/

}
Ndroid21
  • 400
  • 1
  • 8
  • 19
  • Thanks buddy, now i have got some think like this Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\pract\mail.php on line 11 Error! – Sagar Apr 11 '17 at 05:32
  • 1
    This error is because you have not started your mail server, start it. It's name is Mercury in xampp. – Ndroid21 Apr 11 '17 at 05:36
  • And to configure you can refer to this answer here: http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost – Ndroid21 Apr 11 '17 at 05:38
  • ok i have started Mercury, then got something like this Warning: mail(): SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\pract\mail.php on line 11 Error! – Sagar Apr 11 '17 at 05:39