Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])){
- $name = array("alexwawo", "barbara", "geovanta", "habib", "asril");
- $minimum = 5;
- $maximum = 10;
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(strlen($username) < $minimum){
- echo "Username harus memiliki panjang 5 atau lebih";
- }
- if(strlen($username) > $maximum){
- echo "Username tidak boleh lebih panjang dari 10";
- }
- if(!in_array($username, $name)){
- echo "Maaf, akses ditolak";
- }else{
- echo "selamat datang";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>PHP forms</title>
- </head>
- <body>
- <form action="form.php" method="post">
- <input type="text" name="username" placeholder="Enter username" />
- <input type="password" name="password" placeholder="Enter password" />
- <br />
- <input type="submit" name ="submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement