File "php_form_validate_email.php"

Full path: E:/sites/Single15/tinmung2007/webroot/THDC-Hai- Ngoai/hocwebchuan_form_validation/php_form_validate_email.php
File size: 697 B
MIME-type:
Charset: utf-8

Download   Open   Back

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>PHP form</title>
</head>

<body>
<form action="" method="post">
    Email: <input type="email" name="email" value="">
    <button type="submit">Gửi</button>
</form>
<?php 
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["email"])) {
        echo "<span style='color:red;'>Error: Email bắt buộc phải nhập.</span>";
    } else {
        $email = $_POST["email"];
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            echo "<span style='color:red;'>Error: Email nhập chưa đúng.</span>";
        } else {
            echo $email;
        }
    }
}
?>
</body>
</html>

PHP File Manager