I'm really new to PHP and having trouble figuring out how to troubleshoot. I've looked at lot of other issues having similar problems, but I can't get the solutions they're giving to work in my code.
When you submit a form on the following page, the email is sent just as it should be, but the page turns white. I've changed it to target _blank so it makes a new tab that's white, but it's still confusing people.
The webpage is at: http://designbycrisscross.com/contact.html
And here's the contents of contact.php:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$budget = $_POST['budget'];
$message = $_POST['message'];
$human = $_POST['human'];
$to = 'neena@designbycrisscross.com';
$subject = 'New Email from CrissCross Website';
$from = $email;
$body = "From: $name
E-Mail: $email
Budget: $budget
Message:
$message";
mail ($to, $subject, $body, $from);
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo 'Your message has been sent!';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>
If the mail is being sent, then the only possible explanation is that $_POST['submit'] == false (unlikely) or $human != '4' (more likely).
Reasoning: mail($to, $subject, $body, $from) is running on line 14, but it's not making it past the conditional on line 15. If it were to make it past the conditional on line 15, it would have to output at least something.
Try rewriting your conditional to provide more information.
if ($_POST['submit']) {
if ($human == '4') {
if (mail($to, $subject, $body, $from)) {
echo 'Your message has been sent!';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
} else {
trigger_error('Form submission not detected!', E_USER_ERROR);
}