0
<?php
    //Get values passed from login form.html
    $username = $_POST['user'];
    $password = $_POST['psw'];
    
    // to prevent mysql injection
    $username = stripcslashes($username);
    $password = stripcslashes($password);
    $username = mysqli_real_escape_string($username);
    $password = mysqli_real_escape_string($password);
    
    // connect to server and select database
    mysql_connect("localhost", "root", "");
    mysql_select_db("login");
    
    // Query the database for user
    $result = mysql_query("select * from users where username = '$username' and password = '$password'")
            or die("Failed to query database".mysql_error());
    $row = mysql_fetch_array(result);
        if ($row['username'] == $username && $row['password'] == $password){
            echo "Login Successful" $row ['username'];
        }
            else{
                echo "Login Failed please try again";
            }
            
?>

This is the PHP code I'm working with, but I do not know how to manipulate it further, and integrate it with my HTML login page.

KaiserKatze
  • 1,521
  • 2
  • 20
  • 30
  • What do you want to achieve? Any expected behaviour? – KaiserKatze Jan 10 '21 at 06:55
  • Can you tell us what you exactly want, and what you expect to happen and how? – Charbelalam Jan 10 '21 at 07:18
  • I'm trying to get two users from the database, to login.....but now i have two users that need to access two different home pages based on their credentials on the database, but i cannot even get one to do so. – SwiftNinjaR Jan 10 '21 at 08:05
  • 1
    The `mysql_*()` functions were removed in PHP7. You should refactor your code to use `mysqli_*()`, or better, `PDO` – Tangentially Perpendicular Jan 10 '21 at 08:09
  • is that also the case when using myphpadmin, cause thats what im using – SwiftNinjaR Jan 10 '21 at 09:26
  • Not even, beside refactoring theres still the modifying what i have to get two accounts to be redirected to two saparate web pages (that ive prepared already) depending on the password and username they use which is present on the database – SwiftNinjaR Jan 10 '21 at 16:58

0 Answers0