I have just started using mysqli I'm trying to connect to a database and login, I'm getting the error messages,
Notice: Undefined index: ___mysqli_ston in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\course work\login.php on line 14
I'm also trying to display error messages on the page of the form rather than creating a new page which it's currently doing. I forget does the PHP have to be on the same page for the errors to be displayed?
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\course work\login.php on line 14
Could not find database
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
$errors = array();
if ($username&&$password)
{
$connect = mysqli_connect("localhost","root","") or die ("Could not connect");
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE login")) or die ("Could not find database");
$query = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM users WHERE username ='$username'");
$numrows = mysqli_num_rows($query);
if ($numrows !=0)
{
while ($row =mysqli_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
echo header( 'Location: member.php' ) ;
$_SESSION['username']=$dbusername;
$_SESSION['userid']=$userid;
}
else
echo "Inncorrect password";
}
else
die("That user dosen't exist");
}
else
die("Please enter a username and a password");
?>
You should have a database name for
mysqli_connect
. So, go like this:and why are you using
__mysqli_ston
for?Use this insteadDo not use
__mysqli_ston
.This should work.If doesn't work,get back to me.