ho cambiato il codice con le tue correzioni e non va ugualmente
Codice PHP:
<?php
include_once("config.php");
$username = trim($_POST['uname']);
$password = trim($_POST['passw']);
if($username == "" or $password == ""){
header("Refresh: 5;URL=index.php");
$msg= 'Hai inserito dati non corretti ... attendi il reindirizzamento';
} else {
$sql = "SELECT id, temp FROM $_CONFIG['table_utenti'] WHERE password='".$password."' and username='".$username."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($result) {
if ($row['temp'] == 0) {
$sql2 = "INSERT INTO $_CONFIG['table_sessioni'] (username, password, id) VALUES ('".$username."', '".$password."', ".$row['id']."')";
$result2 = mysql_query ($sql2) or die (mysql_error());
if ($result2) {
setcookie ( sessioni ,"$row['id']", "$_CONFIG['expire']");
header("Refresh: 5;URL=index.php");
$msg= 'Login avvenuto con successo';
echo $msg;
}
}
}
}
?>
file associato se può servire
Codice PHP:
<?php
$_CONFIG['host'] = "....";
$_CONFIG['user'] = ".....";
$_CONFIG['pass'] = ".....";
$_CONFIG['dbname'] = "....";
$_CONFIG['table_sessioni'] = "sessioni";
$_CONFIG['table_utenti'] = "Registrazione";
$_CONFIG['expire'] = 0;
//--------------
$conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione');
mysql_select_db($_CONFIG['dbname']);
?>