Login.php
Database connectie:
Error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/a1684280/public_html/login.php on line 58
Hele pagina-code in spoiler-tagWat ik probeer:
Kijken als de "username" en "password" in de database overeenkomen met de ingegeven gebruiksnaam en wachtwoord, en dan hem in te loggen.
Ik heb al jaren geen web-coding gedaan en mysqli is nieuw - Iemand die me kan helpen met dit probleem?
$username = mysqli_real_escape_string($dbc, $_POST[username]);
$password = mysqli_real_escape_string($dbc, $_POST[password]);
$sel_user = "SELECT * FROM users WHERE username = $username AND password = $password";
$run_user = mysqli_query($dbc, $sel_user);
$check_user = mysqli_num_rows($run_user);
if($check_user>0){
$_SESSION[username]=$username;
echo "Logged in"; Database connectie:
$dbc = mysqli_connect(mysql11.000webhost.com, a1684280_*****, *********, a1684280_users); Error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/a1684280/public_html/login.php on line 58
$check_user = mysqli_num_rows($run_user); Hele pagina-code in spoiler-tag
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] [COLOR= #FF8000]//Starting a Session[/COLOR]
[COLOR= #0000BB]$dbc[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_connect[COLOR= #007700]([/COLOR][COLOR= #DD0000]mysql11.000webhost.com[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]a1684280_******[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]********[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]a1684280_users[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Please enter a username and password."[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbc[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbc[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$sel_user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM users WHERE username = $username AND password = $password"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$run_user[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_query[COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbc[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$sel_user[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$check_user[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_num_rows[COLOR= #007700]([/COLOR][COLOR= #0000BB]$run_user[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$check_user[/COLOR][COLOR= #007700]>[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Logged in"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"failed to log in"[/COLOR][COLOR= #007700]; }
}
}[/COLOR]
?>Kijken als de "username" en "password" in de database overeenkomen met de ingegeven gebruiksnaam en wachtwoord, en dan hem in te loggen.
Ik heb al jaren geen web-coding gedaan en mysqli is nieuw - Iemand die me kan helpen met dit probleem?

