Buongiorno!
Ho trovato uno script di registrazioni, una volta configurato tutto db ecc. includo la pagina home.php nella tabella di destra della mia pagina iniziale
home.php:
Codice PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento senza titolo</title>
<style type="text/css">
<!--
.Stile1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
padding-left: 6px;
color:#000000;
}
-->
</style></head>
<body>
<form action="checkuser.php" method="post" name="form1">
<div align="center">
<table width="180" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="Stile1">Utente:</span></td>
</tr>
<tr>
<td class="Stile1"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td class="Stile1">Password:</td>
</tr>
<tr>
<td class="Stile1"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td class="Stile1"><div align="left"><input type="submit" name="Submit" value="Entra"></div></td>
</tr>
</table>
</div>
</form>
</body>
</html>
L'errore sta: una volta fatto il login: benvenuto filippo me lo da in un altra pagina e non sulla collonna di destra della mia pagina cm mai?
Ecco un altro file utile:
checkuser.php
Codice PHP:
<?
/* Check User Script */
session_start(); // Start Session
include 'db.php';
// Convert to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Metti tutte le informazioni per favore!
";
include 'home.php';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
header("Location: sample.php");
}
} else {
echo "Utente e password non validi. Riprova!
";
include 'home.php';
}
?>