questo script dovrebbe permettere di autenticare un utente e memorizzare il suo id presente nella tabella degli utenti del database, ma oltre a darmi dei notice, al comando print non mi restituiesce il risultato desiderato, ma mi dà:il tuo ID utente è: Resource id #3
che significa?
<?php
session_start();
dbconnect();
if ($_REQUEST['action'] == "login") {
$_SESSION['verified_user'] = "";
$result = mysql_query("SELECT id FROM user WHERE nick='".$_REQUEST['username']."' AND pass='".$_REQUEST['psw']."'");
if (mysql_num_rows($result) > 0) list($_SESSION['verified_user']) = mysql_fetch_row($result);
}
?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<br><a href="log-in.php">Log in</a> - <a href="index.php">Index</a> - <a href="log-out.php">Log out</a><br>
<?php
echo"<br>";
if ($_SESSION['verified_user'] != "") {
echo"<b>Welcome.</b><br>";
} else {
if ($_REQUEST['action'] == "login" && $_SESSION['verified_user'] == '') {
echo"<font color=\"red\">Login error!</font><br><br>";
}
?>
<form name="login_form" action="log-in.php" method="post">
<input type="hidden" name="action" value="login">
Username: <input type="text" name="username">
Password: <input type="password" name="psw"> <input type="submit" name"Login" value="Login"></form>
<?php
}
function dbconnect() {
mysql_connect("localhost", "root", "");
@mysql_select_db("film") or die ("Unable to select database");
}
?>
<?php
print("il tuo ID utente è: $result <br>");
?>
</body>
</html>
che significa?
<?php
session_start();
dbconnect();
if ($_REQUEST['action'] == "login") {
$_SESSION['verified_user'] = "";
$result = mysql_query("SELECT id FROM user WHERE nick='".$_REQUEST['username']."' AND pass='".$_REQUEST['psw']."'");
if (mysql_num_rows($result) > 0) list($_SESSION['verified_user']) = mysql_fetch_row($result);
}
?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<br><a href="log-in.php">Log in</a> - <a href="index.php">Index</a> - <a href="log-out.php">Log out</a><br>
<?php
echo"<br>";
if ($_SESSION['verified_user'] != "") {
echo"<b>Welcome.</b><br>";
} else {
if ($_REQUEST['action'] == "login" && $_SESSION['verified_user'] == '') {
echo"<font color=\"red\">Login error!</font><br><br>";
}
?>
<form name="login_form" action="log-in.php" method="post">
<input type="hidden" name="action" value="login">
Username: <input type="text" name="username">
Password: <input type="password" name="psw"> <input type="submit" name"Login" value="Login"></form>
<?php
}
function dbconnect() {
mysql_connect("localhost", "root", "");
@mysql_select_db("film") or die ("Unable to select database");
}
?>
<?php
print("il tuo ID utente è: $result <br>");
?>
</body>
</html>