I am trying to make an if statement that will launch my mail(); php code when an image is clicked.
I have tried this so far:
<?php
$to = "ravncompany@gmail.com";
$subject = $_POST['subject'];
$message = $_POST['TextField'];
$header = "From: MyEmail@email.com";
if (isset($_POST['SendButton'])) {
mail($to, $subject, $message, $header);
}
?>
html
<input type="image" alt="submit form" name="SendButton" id="SendButton" src="./Photos/SendButton.png">
this does not send my email though I am sure it is the if statement that is the problem since if i remove the if statement then it will send an email.
but even if I did get my code to work then i don't think it would cut it since I am making an Ajax web and right now when I press the input image then it refreshes the page. In my case this means it takes me from contact page to home page.
the way my web functions is that i have a Main.php which i load contact.php, home.html, etc... into . So when in contact.php pressing a submit button will refresh the site loading home.html into main.php since home.html is set to default.
So I need to launch an if statement in php when an image is clicked without refreshing the page.
I have tried several things but can't quite get there. can someone help me do this right?