I know there have been a lot of post regarding this, but mine doesn't seem to work off here. The row gets fetched from the database fine but the mail is not sent. Here is my code.
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method = "POST">
<input type = "email" name = "email" placeholder = "Enter Your Email Address" required/>
<input type = "submit" name= "submit" value = "submit"/>
</form>
php code
function sendEmail(){
$to = "someone@gmail.com";
$subject = "the subject";
$message = "First line";
$headers = 'From: someone@example.com' . "\r\n" .'Reply-To: someone@example.com' . "\r\n" .'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
if(isset($_POST['submit']) && $_POST['submit'] == 'submit'){
$email = $_POST['email'];
$sql = $db->prepare("SELECT * from users where email = ?");
$sql->bind_param("s",$email);
$sql->execute();
$sql = $sql->get_result();
if(($getRowCount = $sql->num_rows) == 1){
sendEmail();
}