Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Create connection to XAMPP and its DB
- $connection = mysqli_connect('localhost', 'root', '');
- if(!$connection)
- {
- die("Database connection failed".mysqli_error($connection));
- }
- $select_db = mysqli_select_db($connection, 'fleadbv2');
- if (!$select_db)
- {
- die("Database Selection Failed" . mysqli_error($connection));
- }
- // Get values passed from the html page
- $username = $_POST['loginusername'];
- $password = $_POST['loginpassword'];
- $login = "SELECT * FROM users WHERE username='$username' AND password='$password'";
- session_start();
- // Query the database
- $result = mysqli_query($connection, $login);
- // Places results in an array
- $row = mysqli_fetch_array($result);
- if ($row['username']==$username && $row['password']==$password)
- {
- echo "Welcome, ".$username;
- }
- else
- {
- echo "Login failed. Please check your credentials.";
- }
- ?>
- Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ProjectFlea\login.php on line 26
- Login failed. Please check your credentials.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement