Warning: Undefined array key "login" in C:\xampp\htdocs\unity\login.php on line 3 Warning: Undefined array key "haslo" in C:\xampp\htdocs\unity\login.php on line 4 Fatal error: Uncaught TypeError: mysqli_select_db(): Argument #1 ($mysql) must be of type mysqli, string given in
C:\xampp\htdocs\unity\login.php:10 Stack trace: #0 C:\xampp\htdocs\unity\login.php(10): mysqli_select_db('konta', Object(mysqli)) #1 {main} thrown in C:\xampp\htdocs\unity\login.php on line 10
<?PHP
$user = $_POST['login'];
$pass = $_POST['haslo'];
$con = mysqli_connect("localhost","root","") or ("Blad polaczenia: " . mysqli_error());
if (!$con)
die('Nie mozna polaczayc: ' . mysqli_error());
mysqli_select_db("konta" , $con) or die ("Nie mozna wczytac bazy danych" . mysqli_error());
$check = mysqli_query("SELECT * FROM konta WHERE `login`='".$user."'");
$numrows = mysqli_num_rows($check);
if ($numrows == 0)
{
die ("Podany login nie istnieje \n");
}
else
{
$pass = md5($pass);
while($row = mysqli_fetch_assoc($check))
{
if ($pass == $row['haslo'])
die("login-SUCCESS");
else
die("Bledne haslo. \n");
}
}
?>
CodePudding user response:
Looks like the parameters are in the wrong order mysqli_select_db("konta" , $con) or die ("Nie mozna wczytac bazy danych" . mysqli_error());
should be mysqli_select_db($con, "konta")
CodePudding user response:
Sorry It worked, thanks for all.