My web hosting company says there is something wrong with PHP code

前端 未结 4 1678
北海茫月
北海茫月 2021-01-29 07:46

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

4条回答
  •  余生分开走
    2021-01-29 08:31

    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.

提交回复
热议问题