Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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') VALUES ($username, $password)";
  26.  
  27.     $result = mysqli_query($connection, $query);
  28.  
  29.     if(!$result) {
  30.         die('Query failed');
  31.     }
  32. }
  33. function check($username){
  34.     for($i=0; $i<strlen($username);$i++)
  35.     if($username[$i] == 'a' || $username[$i] == 'e' || $username[$i] == 'i' || $username[$i] == 'o' || $username[$i] == 'u'){
  36.         return true;
  37.     }
  38.     return false;
  39.  
  40. }
  41. ?>
  42.  
  43.  
  44.  
  45. <!DOCTYPE html>
  46. <html lang="en">
  47.     <head>
  48.         <meta charset="UTF-8">
  49.         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  50.  
  51.         <title>This is my first php course</title>
  52.     </head>
  53.     <body>
  54.  
  55.         <div class="container">
  56.  
  57.             <div class="col-sm-6">
  58.                 <form action = "logi.php" method="post">
  59.                     <div class="form-group">
  60.                         <label for="username">Username</label>
  61.                         <input type="text" class="form-control" name="username">
  62.                     </div>
  63.  
  64.                     <div class="form-group">
  65.                         <label for="password">Password</label>
  66.                         <input type="password" class="form-control" name="password">
  67.                     </div>
  68.  
  69.                     <input class="btn-primary" type="submit" name="submit" value="Submit">
  70.                 </form>
  71.             </div>
  72.  
  73.  
  74.         </div>
  75.     </body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement