PHP Scripting

E-mail Validation

PHP example for email validation

6/14/2020
0 views
email-validation.phpPHP
<html>
	<head>
		<title>Email Validation</title>
	</head>
	<body>
		<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
			<input type="email" autocomplete="off" required name="email" placeholder="Enter a email address" />
			<input type="submit" value="Validate" />
		</form>
		<?php
			if(isset($_POST['email'])) {
				$email = $_POST['email'];
   			$valid = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
   			if ($valid)
      				echo "<br />It's a valid email address!";
   			else
	      			echo "<br />It's a invalid email address!";
   		}
		?>
	</body>
</html>



/* Output */
E-mail: a@g
It's a invalid email address!

/* ------------------------------------------ */

E-mail: geek@geekboots.com
It's a valid email address!
PHPemail validationPHP code for email validation

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com