I have like two files, both are in the same and correct folder:
index.php and contactform.php
The form appears, but I want to make if fully functional, so it actually sends an email to my email address. Can someone review the code and tell me what have I done wrong and how can I make it work, so It sends an email to [email protected]?
index.php:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<link="stylesheet" href="index.css"> <!-- zde doplnit odkaz na CSSka -->
</head>
<body>
<p>SEND E-MAIL</p>
<form class="contact-form" action="contactform.php" method="post">
<input type="text" name="name" placeholder="Full name">
<input type="text" name="mail" placeholder="Your-email">
<input type="text" name="subject" placeholder="Subject">
<textarea name="message" placeholder="Message"></textarea>
<button type="submit" name="submit">SEND MAIL</button>
</form>
</body>
</html>
contactform.php:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "[email protected]";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from ".$name.".nn".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.php?mailsend")
}
?>