I’m building an email contact form that sends via the POST method using PHP. the form is at ../register.shtml, and the action redirects to ../register.php
The problem is, when register.php is opened directly (as in not via the form) a blank email sends to my inbox. Is there a way to stop this from happening?
Thanks!
Create a hidden input field in the form on your
../register.shtmlpage. Then, onregister.php, check if the hidden input value is set. If so, then process the form. If it’s not set (the user didn’t come from the form) then redirect back to the original page.Here’s some code:
On
../register.shtmlThen, at the top of
../register.php