buongiorno ,
da quello che mi vate detto , essendo un altro script ho aperto un nuovo topic.
quandofaccioil login, nonmi rimanda alla pagina che voglio tramite header, adesso posto i codici
login.php
Codice PHP:
<?php
include('core.php');
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) || empty($password)) {
echo 'Riempi tutti i campi.<br /><br /><a href="javascript:history.back();">Indietro</a>';
} elseif(mysql_num_rows(mysql_query("SELECT * FROM users WHERE username LIKE '$username'")) == 0) {
echo 'Username non trovato.<br /><br /><a href="javascript:history.back();">Indietro</a>';
} else {
$password = md5($password);
$ip = $_SERVER['REMOTE_ADDR'];
if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE username LIKE '$username' AND password='$password'")) > 0) {
$username = mysql_result(mysql_query("SELECT username FROM users WHERE username LIKE '$username'"), 0);
$userid = mysql_result(mysql_query("SELECT id FROM users WHERE username LIKE '$username'"), 0);
mysql_query("UPDATE users SET last_login='".time()."', last_ip='$ip' WHERE id='$userid'") or die(mysql_error());
$_SESSION['username'] = $username;
$_SESSION['userid'] = $userid;
header('Location: chat.html');
}
}
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<label>Username: <input type="text" name="username" required maxlength="16" /></label><br />
<label>Password: <input type="password" name="password" required maxlength="20" /></label><br />
<input type="submit" name="login" value="Accedi" />
</form>
<?php
}
?>
chat.html
Codice HTML:
<html>
<head>
<title>
</title>
</head>
<body>
<a href="/gabrieleanna/sitogabrieleanna.html">gabriele-anna</a>
<a href="/mircogabriele/sitomircogabriele.html">mirco-gabriele</a>
<a href="/mircoanna/sitomircoanna.html">mirco-anna</a>
</body>
</html>
qualcuno sa come risolvere. grazie per coloro che risponderanno