Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3.  
  4. $name = array("alexwawo", "barbara", "geovanta", "habib", "asril");
  5.  
  6. $minimum = 5;
  7. $maximum = 10;
  8.  
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12. if(strlen($username) < $minimum){
  13. echo "Username harus memiliki panjang 5 atau lebih";
  14. }
  15.  
  16. if(strlen($username) > $maximum){
  17. echo "Username tidak boleh lebih panjang dari 10";
  18. }
  19.  
  20. if(!in_array($username, $name)){
  21. echo "Maaf, akses ditolak";
  22. }else{
  23. echo "selamat datang";
  24. }
  25.  
  26. }
  27. ?>
  28.  
  29. <!DOCTYPE html>
  30. <html>
  31. <head>
  32. <title>PHP forms</title>
  33. </head>
  34. <body>
  35.  
  36. <form action="form.php" method="post">
  37. <input type="text" name="username" placeholder="Enter username" />
  38. <input type="password" name="password" placeholder="Enter password" />
  39. <br />
  40. <input type="submit" name ="submit" />
  41. </form>
  42.  
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement