Until now I had a PHP Kontaktform with empty textfields and checked the needed fields with:
$name = check_input($_POST['name'], "Please enter a Name.");
Now the lable "your name" is in it the textfield itself. So the value is not empty anymore. How do I check if there's still only "your name" in the field instead of a real name?
Thank you (sorry php-noob)
use the HTML5 placeholder tag in the first place.
<input placeholder="Your Name" value="" name="name">
or, if that is not possible, check for that given string:
$name = (strstr('your name', $_POST['name']) ? '' : check_input($_POST['name'], "Please enter a Name."));
Compare $name
to "your name"
. If they are the same, then you didn't get an actual name.
for example
if ($name == "your name") {
// do stuff
} else {
// they have a valid name
}
You can do like this :
$name = isset( $_POST['name'] ) ? ($_POST['name'] == 'your name' ? '' : $_POST['name']) : '';
$name = check_input($name, "Please enter a Name.");