Hi Guys,

I'm having a few issues, I have managed yo let users register this works fine. But When the registerd user tries to log into the site I'm getting the following error message

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\login.php on line 16

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\login.php on line 16

This is my code

<?php
// checkLogin.php

session_start(); // Start a new session
require('config.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['username'];
$password = $_POST['password'];

// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);

$sqli = "select * from 'users' where username = '$username' and password = '$password'";

$result = mysqli_query($sqli) or die ( mysqli_error() );
$count = 0;
while ($line = mysqli_fetch_assoc($result)) {

     $count++;
     }
if ($count == 1) {

     $_SESSION['loggedIn'] = "true";

     header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to

} else {

     $_SESSION['loggedIn'] = "false";

     header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login

}

 ?>

Any ideas? All help is much appreicated

Se the manual - the procedural style part. The mysqli_query expects two parameters, the link and the query. Similar goes for the mysqli_error. It expects the link in procedural version.

try changing your dashes
you have

$sqli = "select * from 'users' where username = '$username' and password = '$password'";

try (look at the users)

$sqli = "select * from `users` where username = '$username' and password = '$password'";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.