php - How to check for an @ in an email address from a form post -


i have form login , registration.

my form

<form method="post" action="login.php">     <input type="text" name="mail" value="input email"/>     <input type="submit" value="check"/> </form> 

if enters email, want check if there @ in address. have tried using array, not working.

you can use php function strpos http://php.net/strpos

if(strpos($myemailpostvariable, '@') === false) {     // things here failed } 

if fixed on using array use explode http://php.net/explode

$parts = explode('@', $myemailpostvariable); if(count($parts) != 2) {     // things here failed } 

keep in mind array way not great searching string easier , faster , more readable.

as @jeroen has suggested if want validate email using filter_input() best...

if(filter_input(input_post, 'mail', filter_validate_email) === false) {     // things here failed } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -