I'm trying to get this contact form to work with the action in the same document.
This is what I currently have:
<?php
function submitfunc() {
$EmailTo = prep($sObj->email);
$Subject = "The reason why your submission got rejected.";
$Message = Trim(stripslashes($_POST['Message']));
$header = "From: info@website.com\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
// prepare email body text
$Body = "";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, $header);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=succes.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
}
?>
<?php
if(isset($_GET['action'])=='submitfunc') {
submitfunc();
}else { ?>
<form method="post" action="?action=submitfunc">
<textarea placeholder="Describe why the image got rejected..." name="Message" rows="3" cols="20" id="Message"></textarea>
<input type="submit" name="submit" value="No + send message" class="btn btn-large btn-danger" />
</form>
<?php } ?>
Whenever I try to run this, I get taken to the error.htm page. How can I solve this issue?
Edit: I've added $header to my mail. Still not working.