E-mail Validation

		<title>Email Validation</title>
		<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" />
			if(isset($_POST['email'])) {
				$email = $_POST['email'];
   			$valid = ereg("^[^@ ][email protected][^@ ]+\.[^@ \.]+$", $email);
   			if ($valid)
      				echo "<br />It's a valid email address!";
	      			echo "<br />It's a invalid email address!";

/* Output */
E-mail: [email protected]
It's a invalid email address!

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

E-mail: [email protected]
It's a valid email address!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!