ciao,
sono appena passato da php 4.xx a php 5.2.3
e da apache 1.xx a 2.2
e mysql 5.0
ho uno script di login che non mi funziona più....
in pratica all'autenticazione non mi accetta lo user e psw che avevo e che esiste controllando con phpmyadmin. ho provato anche a crearne uno di nuovo sempre da phpmyadmin, ma niente da fare, non me lo accetta.
c'è forse qualche problema da php 4 a 5?
cmq questo è lo script per autenticazione:
grazieCodice PHP:
function doLogin()
{
// if we found an error save the error message in this variable
$errorMessage = '';
$userName = $_POST['txtUserName'];
$password = $_POST['txtPassword'];
// first, make sure the username & password are not empty
if ($userName == '') {
$errorMessage = 'Devi inserire il nome utente';
} else if ($password == '') {
$errorMessage = 'Devi inserire la password';
} else {
// check the database and see if the username and password combo do match
$sql = "SELECT user_id
FROM tbl_user
WHERE user_name = '$userName' AND user_password = PASSWORD('$password')";
$result = dbQuery($sql);
if (dbNumRows($result) == 1) {
$row = dbFetchAssoc($result);
$_SESSION['plaincart_user_id'] = $row['user_id'];
// log the time when the user last login
$sql = "UPDATE tbl_user
SET user_last_login = NOW()
WHERE user_id = '{$row['user_id']}'";
dbQuery($sql);
// now that the user is verified we move on to the next page
// if the user had been in the admin pages before we move to
// the last page visited
if (isset($_SESSION['login_return_url'])) {
header('Location: ' . $_SESSION['login_return_url']);
exit;
} else {
header('Location: index.php');
exit;
}
} else {
$errorMessage = 'Nome Utente e/o password errati';
}
}
return $errorMessage;
}