added some more tests to block bots calling the script directly
This commit is contained in:
parent
1bce64b722
commit
eb6e496989
@ -1,6 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
// inspired by: https://www.unixdude.net/posts/2017/Nov/29/pelican-contact-form/
|
// inspired by: https://www.unixdude.net/posts/2017/Nov/29/pelican-contact-form/
|
||||||
|
|
||||||
|
// make sure method is POST
|
||||||
|
if ( $_SERVER['REQUEST_METHOD'] != 'POST' ) {
|
||||||
|
header('Location: /');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure all required fields are set
|
||||||
|
// HTML already validates this, but bots sometimes call the script directly
|
||||||
|
if ( $_POST['name'] == '' or $_POST['email'] == '' or $_POST['nachricht'] == '') {
|
||||||
|
header('Location: /');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// The 'address' form field is in the code but doesn't get rendered on the page. The message will only get sent if the field is empty, thus weeding out bots that will just fill out any form field
|
// The 'address' form field is in the code but doesn't get rendered on the page. The message will only get sent if the field is empty, thus weeding out bots that will just fill out any form field
|
||||||
if ( $_POST['address'] != '' ) {
|
if ( $_POST['address'] != '' ) {
|
||||||
header('Location: /');
|
header('Location: /');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user