Reputation: 10076
All, I have a contact form on my page. I've got some jQuery things to contorl the form submission and I also have some PHP validation before I send the form. I'm still getting some blank emails. I make the email address and name a required field. I then have the following PHP:
<?php
$email = $_POST['email'];
if($email != ""){
//send email
}
I'm still getting emails though. Would use the empty function work? I'm just trying to make sure there is actually text in the field for it to send instead of being able to send the blank form. What methods do people use to control this?
Thanks in advance!
Upvotes: 0
Views: 103
Reputation: 5731
Perhaps you should trim your string to avoid the use of blank spaces:
<?php
$email = trim($_POST['email']);
if(!empty($email)){
//send email
}
More info: http://www.php.net/manual/en/function.trim.php
Upvotes: 0