Created
May 6, 2018 22:39
-
-
Save edward-jimenez/2f93eb36c358e19da793e037400c4ac1 to your computer and use it in GitHub Desktop.
Check whether a POST variable contains the '@' symbol in an email input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Checking if an email address contains the '@' symbol | |
using the PHP strpos function | |
*/ | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Email Checker</title> | |
</head> | |
<body> | |
<?php if($_SERVER['REQUEST_METHOD'] == 'GET') { ?> | |
<form method="POST" action="email-check.php" > | |
<input type="email" name="email" placeholder="email" /> | |
<input type="submit" name="submit" value="Submit" /> | |
</form> | |
<?php } else { | |
/* Returns the position of the '@' symbol. If it is not found | |
then false is returned. | |
*/ | |
if(strpos($_POST['email'], '@') === false ) { | |
print 'There was no @ in the e-mail address!'; | |
} | |
} ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment