phpメールボックス検証

8620 ワード


$reply = '';
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
        $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
        if (preg_match($pattern,$email,$match)) {
            print_r($match);
            $user_name = preg_replace($pattern,"$1",$email);
            $domain_name = preg_replace($pattern,"$2",$email);
            $reply .= "".$user_name."
"
; $reply .= "".$domain_name.'
'
; } else { $reply = ' '; } } ?> /span>html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Documenttitle> head> <body> <h1> h1> <form action="" method="post"> <input type="text" name="email"> <input type="submit" value=" "> form> echo $reply;?> body> html>