Making email field required in php -



Making email field required in php -

i have php script capture of name , email address mailing list. if possible please offer adivce on how create email , name fields required, user forced input name , email form fields.

again much appreciated help !!

the next php code beingness used form

<?php $sendto = "info@mail.com"; $subject = "website email enquiry"; $headers = "from: " . $_post["firstname"] ." ". $_post["lastname"] . "<" . $_post["email"] .">\r\n"; $headers .= "reply-to: " . $_post["email"] . "\r\n"; $headers .= "return-path: " . $_post["email"]; $message = $_post["message"]; mail($sendto, $subject, $message, $headers); ?>

you have check values of $_post['firstname'], $_post['lastname'] , $_post['email']

for the name, can check :

empty()

if ( empty($_post['firstname']) || empty($_post['lastname']) ) // grab error

you can also, utilize strlen() , trim() check string size , not validate name 1 character length.

for email, can check :

filter validate

if ( !filter_var($_post['email'], filter_validate_email) ) // grab error

php email requiredfieldvalidator

Comments