I have a very simple contact form on my website, but unfortunetly it's not working at all.
What's going on is that when I click "submit" button, the site is becoming blank and the mail is not beeing sent to my inbox (I do not use gmail).
Code:
PHP:
<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$topic = $_POST['topic'];
$message = $_POST['message'];
$mailTo = "xxxx@yyyy.zz";
$headers = "From: ". $email;
$txt = "You've received a message from: ".$name.".\n"."Subject: ".$topic."\n\n".$message;
mail($mailTo, $topic, $txt, $headers);
//header("Location: index.pxp?mailsend");
}
?>
HTML:
<form method="post" class="contact-form" action="contactform.php">
<label for="name">Full name</label>
<input type="text" name="name" id="name" placeholder="Full name *" required>
<label for="email">Email</label>
<input type="text" name="email" id="email" placeholder="example@example.com *" required>
<label for="topic">Subject</label>
<input type="text" name="topic" id="topic" placeholder="Subject *" required>
<label for="message">Message</label>
<textarea name="message" id="message" placeholder="Enter your message here" required></textarea>
<input class="submit_button" type="submit" name="submit" value="Submit" onclick="Submitting_error()">
</form>
Can someone explain to me why the contact form is not working, and if you're willing to help additionally, can You fix my php (and if needed, html) code?
I added this onclick funtction to let user know that contact form is not working now onclick="Submitting_error()"
after the problem is resolved I'll remove this.
Thanks in advance :)