/* PHP */ $msg = ''; $msgClass=''; if(filter_has_var(INPUT_POST,'submit')){ $name = htmlspecialchars($_POST['name']); $email = htmlspecialchars($_POST['email']); $message = htmlspecialchars($_POST['message']); if(!empty($email) && !empty($name) && !empty($message)){ // Passed // Check Email if(filter_var($email, FILTER_VALIDATE_EMAIL)===false){ $msg = 'Please use a valid email'; $msgClass = 'alert-danger'; } else { //Passed } } else{ // Failed $msg = 'Please fill in all fields'; $msgClass = 'alert-danger'; } } /* PHP */ <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PILSOOK LEE</title> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body > <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand">FORM CHECK</a> </div> </div> </nav> <div class="container"> /* PHP */ if($msg != ''): /* PHP */ <div class="alert /* PHP */ echo $msgClass;/* PHP */"> /* PHP */ echo $msg; /* PHP */ /* PHP */ endif; /* PHP */ <form method="post" action="/* PHP */ echo $_SERVER['PHP_SELF']; /* PHP */"> <div class="form-group"> <label>Name</label> <input type="text" name="name" class="form-control" value="/* PHP */echo isset($_POST['name']) /* PHP */ $name : ''; /* PHP */"> </div> <div class="form-group"> <label>Email</label> <input type="text" name="email" class="form-control" value="/* PHP */ echo isset($_POST['email']) /* PHP */ $email : ''; /* PHP */"> </div> <div class="form-group"> <label>Message</label> <textarea name="message" class="form-control">/* PHP */ echo isset($_POST['message']) ? $message : ''; /* PHP */</textarea> </div> <br> <button type="submit" name="submit" class="bte bte-primaary">Submit</button> </form> </div> </body>
Top Go to Next



main