You are on page 1of 2

Name :- Abhishek Bagal Practical no:14

Roll no:-57

Write a PHP program for sending and receiving plain text


message (e-mail).

 Program:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Validation</title>
</head>
<body>
<form method="post" action="validateEmail.php">
<br><br>Email id <input type="text" name="email">
<br><br><input type="submit" name="submit" value="Check">
</form>

<?php
$msg = 0;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$pattern = '/\b[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}\b/';
if (preg_match($pattern, $_POST['email'])) {
echo "<br>Valid email";
} else {
echo "<br>Enter a valid email address";
}
}
?>
</body>
</html>

1
 Output:-

You might also like