Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Filter Variable
- * https://www.w3schools.com/php/php_ref_filter.asp
- */
- $email = "xossarif@gmail.com";
- if (filter_var($email, FILTER_VALIDATE_EMAIL)){
- //echo "This is a valid email";
- }else{
- // echo "This is not valid Email address";
- }
- echo "<br/>";
- $int = 213243.23234;
- if (filter_var($int, FILTER_VALIDATE_INT)){
- //echo "this is Int";
- }else{
- //echo "this is not";
- }
- echo "<br/>";
- if (isset($_REQUEST['submit'])){
- $email = $_REQUEST['email'];
- if (isset($email)){
- $email_data_sanitize = filter_var($email, FILTER_SANITIZE_EMAIL);
- $email_data_validate = filter_var($email_data_sanitize, FILTER_VALIDATE_EMAIL);
- if ($email_data_validate && $email_data_validate){
- echo "$email is correct";
- }else{
- $error = "$email is Incorrect";
- }
- }
- }
- ?>
- <!doctype 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>Document</title>
- </head>
- <body>
- <form action="" method="POST">
- <input type="text" placeholder="Email" name="email"> <br/>
- <input type="submit" name="submit" value="submit">
- </form>
- <p><?php if (isset($error)){
- echo $error;
- } ?></p>
- </body>
- </html>
Add Comment
Please, Sign In to add comment