I have created the contact form using HTML and PHP. Also, the mail is coming correctly to mail id. But after the success message, it is redirecting to the form.php
page can someone please help me. It is my first time trying to build a website.
Here is my code for contact form:
<form method="post" action="form.php">
<input name="name" required="required" placeholder="Your Name">
<input name="email" type="email" required="required" placeholder="Your Email">
<div class="clearfix"> </div>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<div class="submit">
<input id="submit" name="submit" type="submit" value="Submit">
</div>
</form>
here is my form.php
:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: agriindiaexp.com';
$to = '[email protected]';
$subject = 'Email Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
$success = "Message successfully sent";
} else {
$success = "Message Sending Failed, try again";
}
}
?>
Please help me.
<form method="post" action="/">
and add your form request php code to this page – Faience