0

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.

Laurenz
  • 91
  • 5
  • Have you checked your error logs? – Jay Blanchard Jun 30 '16 at 19:34
  • Hello Jay, thank you for responding! I've read the link that you've provided. They tell me to add Headers to my mail. I've tried to add them, but it still isn't working. (I've updated my code in my first post) I can't access the error log. When I check phpinfo(); it says: Error log no value – Laurenz Jun 30 '16 at 20:02

0 Answers0