Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- echo "Yes! We got the information";
- $username = $_POST['username'];
- $password = $_POST['password'];
- //Connecting to database
- $connection = mysqli_connect('localhost', 'root', '', 'loginapp');
- if($connection) {
- echo "We are accesing the database";
- } else {
- die("You are far away from database");
- }
- if(strlen($username) == 5 && check($username) == true) {
- echo "Username is appropriate!!!Thanks ya for visiting!";
- }
- $query = "INSERT INTO users (username,password) VALUE('$username','$password')";
- if($query)
- {
- echo $query;
- }
- $result = mysqli_query($connection, $query);
- if(!$result) {
- die('Query failed');
- }
- }
- function check($username){
- for($i=0; $i<strlen($username);$i++)
- if($username[$i] == 'a' || $username[$i] == 'e' || $username[$i] == 'i' || $username[$i] == 'o' || $username[$i] == 'u'){
- return true;
- }
- return false;
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <title>This is my first php course</title>
- </head>
- <body>
- <div class="container">
- <div class="col-sm-6">
- <form action = "logi.php" method="post">
- <div class="form-group">
- <label for="username">Username</label>
- <input type="text" class="form-control" name="username">
- </div>
- <div class="form-group">
- <label for="password">Password</label>
- <input type="password" class="form-control" name="password">
- </div>
- <input class="btn-primary" type="submit" name="submit" value="Submit">
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement