Ciao
Capito. hai letto le osservazioni che ti ho fatto ??? Sta sulla modifica del messaggio a cui hai appena risposto.
Capito. hai letto le osservazioni che ti ho fatto ??? Sta sulla modifica del messaggio a cui hai appena risposto.
$usn=htmlspecialchars(trim($_POST['username']));
$pas=md5(trim($_POST['password']));
<link rel="stylesheet" type="text/css" href="coloredisfondo.css">
<?php
require_once("connetti.php");
session_start();
if(isset($_COOKIE["ultimoaccesso"])) {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$ultimo_cookie = $_COOKIE["ultimoaccesso"];
$me= "Il tuo ultimo accesso è stato il: $ultimo_cookie";
} else {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$me= "Non ti sei mai collegato a questa pagina";
}
session_start();
$stringa= strtoupper($_SESSION['nome']);
if(isset($_SESSION['nome'])) {
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>benvenuto</title>
<body>
<?php
$stringa= strtoupper($_SESSION['nome']);
if (ifsset($_SESSION['nome'] = $nome)) {
//if(isset($_SESSION['nome'] )) {
echo "Ciao " . $_SESSION['nome'];
echo "Accesso non consentito";
}
echo "<div class=\"messaggio\"><h1>";
echo "BENVENUTO ".$stringa." <br />";
echo $me;
echo "</h1></div>";
echo "</body></html>";
}else{
header("Location:failed.html");
exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<center> <br> <br>
<input type="button" onClick="window.location.href='logout.php';" style='padding:10px' value="Logout" />
</center>
</body>
</html>
create table utenti (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
nome VARCHAR(30) NOT NULL,
cognome VARCHAR(30) NOT NULL,
username VARCHAR(30) NOT NULL,
email VARCHAR(40) NOT NULL,
password VARCHAR(255) NOT NULL,
attivo ENUM('1', '0') DEFAULT '0',
PRIMARY KEY (id)
);
ciao
hai ragine errore di copy/paste
correggi
$usn=htmlspecialchars(trim($_POST['username']));
$pas=md5(trim($_POST['username']));
in
anche se un errore del genere avresti dovuto saperlo correggere tu.PHP:$usn=htmlspecialchars(trim($_POST['username'])); $pas=md5(trim($_POST['password']));
se poi non ti fa entrare ancora può essere che l'errore sia nella tabella o nella pag riservata
<?php
ob_start();//visto che usi header popo l'l'uotput html
session_start();//aggiungi questa e
if(isset($_POST['log'])){
require_once("connetti.php");
$usn=htmlspecialchars(trim($_POST['username']));
$pas=md5(trim($_POST['username']));
//................
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$usn;// questa
header("location: paginaris.php");
}else{
//.........
?>
hai scrtitto male, hai messo una f in più: isset()Fatal error: Call to undefined function ifsset() in /volume1/web/utenti/fabio/MegaLaboratorio/paginaris.php on line 38
<?php
$stringa= strtoupper($_SESSION['nome'] );
if (isset($_SESSION['nome'] = $nome)) {
//if(isset($_SESSION['nome'] = $nome )) {
echo "Ciao " . $_SESSION['nome'];
echo "<div class=\"messaggio\"><h1>";
echo "BENVENUTO ".$stringa." <br />";
echo $me;
echo "</h1></div>";
echo "</body></html>";
}else{
header("Location:failed.html");
exit();
}
?>
//....
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$usn;// da qui dove crei la sessione
header("location: paginaris.php");
}else{
//.....
//....
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$usn;// da qui dove crei la sessione
header("location: paginaris.php");
}else{
//.....
$usn=htmlspecialchars(trim($_POST['username']));
$nme = mysql_real_escape_string(strtolower(trim ($_POST['nome'])));
//....
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$nome;// da qui dove crei la sessione
header("location: paginaris.php");
}else{
//.....
?php
ob_start();//visto che usi header popo l'l'uotput html
session_start();//aggiungi questa e
require_once("connetti.php");
if(isset($_POST['log'])){
$usn=htmlspecialchars(trim($_POST['username']));
$pas=md5(trim($_POST['password']));
//$nome = mysql_real_escape_string(strtolower(trim ($_POST['nome'])));
//$q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas' ");
$q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas' ");
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$usn;// questa
header("location: paginaris.php");
}else{
header("location: login.php");
}
exit();
}else{
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>form di log</title>
</head>
<body>
<center>
<!--a che cavolo serve questo link? o clicko o inserisci -->
<h2>DIGITARE USERNAME & PASSWORD. PREMERE <a href="iscrizione.php"> QUI</a> </h2>
<form action= "<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<font face="Comic Sans MS">
Username: <input type="text" name="username" maxlength="30" size ="32"> <br /> <br />
Password: <input type="password" name="password" maxlength="12" size ="14"><br /><br />
</font>
<input type="submit" name="log" value="Loggati" />
</form>
<!-- qui il tag center (obsoleto) era indentato col form -->
</center>
</body>
</html>
<?php
}
ob_end_flush();
?>
<link rel="stylesheet" type="text/css" href="coloredisfondo.css">
<?php
require_once("connetti.php");
session_start();
if(isset($_COOKIE["ultimoaccesso"])) {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$ultimo_cookie = $_COOKIE["ultimoaccesso"];
$me= "Il tuo ultimo accesso è stato il: $ultimo_cookie";
} else {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$me= "Non ti sei mai collegato a questa pagina";
}
session_start();
$stringa= strtoupper($_SESSION['nome']);
if(isset($_SESSION['nome'])) {
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
?>
<?php
$stringa= strtoupper($_SESSION['nome'] );
if(isset($_SESSION['nome'])) {
echo "<div class=\"messaggio\"><h1>";
echo "BENVENUTO ".$stringa." <br />";
die();
echo $me;
echo "</h1></div>";
echo "</body></html>";
}else{
header("Location:failed.html");
exit();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>benvenuto</title>
<body>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<center> <br> <br>
<input type="button" onClick="window.location.href='logout.php';" style='padding:10px' value="Logout" />
</center>
</body>
</html>
$q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas' AND attivo =1");
$q=mysql_query("SELECT username, password attivo FROM utenti WHERE username='$usn' AND password='$pas' AND username='$usn' AND attivo ='1'");
ciao
solo qui
PHP:$q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas' AND attivo =1");
<?php
ob_start();//visto che usi header popo l'l'uotput html
session_start();
if(isset($_POST['log'])){
require_once("connetti.php");
$usn=htmlspecialchars(trim($_POST['username']));
$pas=md5(trim($_POST['username']));
//................
$q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas'");
if(mysql_num_rows($q) > 0){
$_SESSION['nome']=$usn;
$riga=mysql_fetch_array($q);//aggiungi questa e
$_SESSION['nome_utente']=$riga['nome'];//questa
header("location: paginaris.php");
}else{
//.........
?>
ciao
sempre dove fai la verifica dell'user e pass
estrai il nome e lo metti in sessione, sessione che poi userai dove vuoi
aggiungi le righe indicate
PHP:<?php ob_start();//visto che usi header popo l'l'uotput html session_start(); if(isset($_POST['log'])){ require_once("connetti.php"); $usn=htmlspecialchars(trim($_POST['username'])); $pas=md5(trim($_POST['username'])); //................ $q=mysql_query("SELECT * FROM utenti WHERE username='$usn' AND password='$pas'"); if(mysql_num_rows($q) > 0){ $_SESSION['nome']=$usn; $riga=mysql_fetch_array($q);//aggiungi questa e $_SESSION['nome_utente']=$riga['nome'];//questa header("location: paginaris.php"); }else{ //......... ?>
$_SESSION['nome_utente']=$riga['nome'];//questa
$_SESSION['nome']=$riga['nome'];//questa