I have a login form but when I put in a username and password that matches the account in my database I get the following error:
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\Louis-Colucci-Proj-1-1\login.php on line 26
I see that it wants the argument changed, but not sure how so? Also, I know the form needs more security, but right now I just want to get the basic implmementation down, then I can work on some encryption. Any help is greatly appreciated! Here is the php code:
<?php
define('DB_NAME', 'conference');
define('DB_USER', 'root');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
mysqli_set_charset($link, 'utf8');
if (!$link) {
die("Database connection failed: " . mysqli_error($connection));
}
$username = $_POST['username'];
$password = $_POST['password'];
function SignIn()
{
session_start();
if(!empty($_POST['username']))
{
$query = mysqli_query("SELECT * FROM users where username = '$_POST[username]' AND password = '$_POST[password]'", MYSQLI_STORE_RESULT) or die(mysql_error());
$row = mysqli_fetch_array($query) or die(mysql_error());
if(!empty($row['username']) AND !empty($row['password']))
{
$_SESSION['username'] = $row['password'];
echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
}
else
{
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
}
if(isset($_POST['submit']))
{
SignIn();
}
?>
Aucun commentaire:
Enregistrer un commentaire