This is the PHP it suppose to connect to a contact.html page and then a thank you page after afterwards.I just wanted a contact form. it wont recognize files as .php.I did save
Assuming that you wish to run this from a form, you will need to set your HTML form tag as follows:
You should then rename contact.html
to contact.php
(any text editor should be able to do this easily).
Finally, you're using PHP's header()
function, which will cause errors if you have output to the browser before it is called. This includes using PHP's echo
struct. Your contact.php
file should look like this (and be in the same directory as your HTML file containing the form):
Something went wrong, go back and try again!';
}
}
else
{
echo 'You answered the anti-spam question incorrectly!
';
}
}
else
{
echo 'You need to fill in all required fields!!
';
}
}
?>
Note: I fixed your layout a little and changed some of the conditions that you were using. The first elseif
was actually redundant, and an else
will suffice.