Web Technologies

Web Technologies 

Slip25

Q.1)  Design a HTML form to accept email address from the user. Write a PHP function using regular expressions check for the validity of entered email-id. The @ symbol should not appear more than once. The dot (.) can appear at the most once before @ and at the most twice or at least once after @ symbol. The substring before @ should not begin with a digit or underscore or dot or @ or any other special character. [Marks30] 

Solution

a.php
<?php 
$email = $_POST['t1'];
$regex = "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$^"; 
if ( preg_match($regex,$email ) ) 

echo $email . " is a valid email. We can accept it.";
 }
 else 
{
 echo $email . " is an invalid email. Please try again."; 

?>

b.html
<html>
<body>
<form action="a.php" method="post">
Enter Email<input type="text" name="t1">
<input type="submit">
</body>
</html>
BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post