[Solved] Trying to convert mysql to mysqli, not working


Just for a quick testing purpose, try this below which is a bare bones method.

You can then slowly build up sanitizing and troubleshoot from thereon.

<?php
$username = $_POST['username'];
$password = sha1($_POST['password']);

$link = mysqli_connect('xxx', 'xxx', 'xxx', 'xxx');

$query = "SELECT password, id FROM users 
WHERE username="$username" AND password='$password'";

$result = mysqli_query($link, $query);

if(mysqli_num_rows($result) < 1) 
{
echo 'Sorry, your username and/or password was incorrect.';
}

else
{
echo "Welcome!";
}
?>

Footnote: I noticed in your original code that you are using sessions.

I did not see session_start(); in your code, nor any mention of it.

This needs to be at the top of your code and inside all your files used,
which will be needed in order to access anything currently in $_SESSION

More on sessions can be found on the PHP.net Website.

8

solved Trying to convert mysql to mysqli, not working