Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4.  
  5. if(isset($_POST['submit'])) {
  6. echo "Yes! We got the information";
  7.  
  8.  
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12. //Connecting to database
  13. $connection = mysqli_connect('localhost', 'root', '', 'loginapp');
  14.  
  15. if($connection) {
  16. echo "We are accesing the database";
  17. } else {
  18. die("You are far away from database");
  19. }
  20.  
  21. if(strlen($username) == 5 && check($username) == true) {
  22. echo "Username is appropriate!!!Thanks ya for visiting!";
  23. }
  24.  
  25. $query = "INSERT INTO users (username,password) VALUE('$username','$password')";
  26.  
  27. if($query)
  28. {
  29. echo $query;
  30. }
  31. $result = mysqli_query($connection, $query);
  32.  
  33. if(!$result) {
  34. die('Query failed');
  35. }
  36. }
  37. function check($username){
  38. for($i=0; $i<strlen($username);$i++)
  39. if($username[$i] == 'a' || $username[$i] == 'e' || $username[$i] == 'i' || $username[$i] == 'o' || $username[$i] == 'u'){
  40. return true;
  41. }
  42. return false;
  43.  
  44. }
  45. ?>
  46.  
  47.  
  48.  
  49. <!DOCTYPE html>
  50. <html lang="en">
  51. <head>
  52. <meta charset="UTF-8">
  53. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  54.  
  55. <title>This is my first php course</title>
  56. </head>
  57. <body>
  58.  
  59. <div class="container">
  60.  
  61. <div class="col-sm-6">
  62. <form action = "logi.php" method="post">
  63. <div class="form-group">
  64. <label for="username">Username</label>
  65. <input type="text" class="form-control" name="username">
  66. </div>
  67.  
  68. <div class="form-group">
  69. <label for="password">Password</label>
  70. <input type="password" class="form-control" name="password">
  71. </div>
  72.  
  73. <input class="btn-primary" type="submit" name="submit" value="Submit">
  74. </form>
  75. </div>
  76.  
  77.  
  78. </div>
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement