Ragazzi ho bisogno del vostro aiuto per gestire una sessione..
questo e il codice del login:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="md5.js" type="text/javascript"></script>
<script type="text/javascript">
function criptazione_pass_login(){ var ie43 = (document.all) ? true : false; var ns43 = (document.layers) ? true : false; var ns63 = (document.getElementById && !document.all) ? true : false; if (ie43) {myform_login=document.all['form_login'];} if (ns43) {myform_login=document.layers['form_login'];} if (ns63) {myform_login=document.getElementById('form_login' );} login_access(); }
</script>
<script>
var time_variable;function getXMLObject() {var xmlHttp = false;try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") }catch (e) {try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e2) {
xmlHttp = false
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}
var xmlhttp= new getXMLObject();
function login_access() {
var getdate = new Date();
if(xmlhttp) {
document.getElementById('load_login').innerHTML ="<img src=\"loading.gif\" alt=\"loading\"></img>";
var email = document.getElementById('email_login1').value;
var pass = document.getElementById('password_nascosta_login') .value;
var parameters="email="+email+"&pass="+pass
xmlhttp.open("POST","login.php",true);
xmlhttp.onreadystatechange = handleServerResponse;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(parameters);
}
}
function handleServerResponse() {
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
if(xmlhttp.responseText=="1"){
document.getElementById('load_login').innerHTML ="errore login";
}
else{
document.getElementById('load_login').innerHTML ="ok";
window.location="utente.php";
}
}else{
alert("Problema chiamata");
}
}
}
</script>
</head>
<body>
<form action="" method="post" name="form_login">
email:<input type="text" id="email_login1" name="email_login"/>
password:<input type="password" id="pass" name="password_login" />
<input type="hidden" name="hash_login" id="password_nascosta_login" size="10">
<label>
<select name="tipologia_login" id="tipologia_login1">
<option value="Privato">Privato</option>
<option value="Azienda">Azienda</option>
<option value="Ente">Ente</option>
</select>
</label>
<input type="button" value="login" onclick="hash_login.value = hex_md5(password_login.value);criptazione_pass_log in();" />
<div id="load_login"></div>
</form>
</body>
</html>
e questo funziona bene ora posto login.php
<?php
session_start();
$email=$_POST['email'];
$pass=$_POST['pass'];
$pass1=md5($pass);
$conn=mysql_connect("localhost","**","****");
if(!$conn)
{
echo"IMPOSSIBILE CONNETTERSI";
exit();
}
$db=mysql_select_db("hellocom_hello");
if(!$db)
{
echo"IMPOSSIBILE APRIRE DATABASE";
exit();
}
$dati="SELECT id FROM registrazione_utente where password_md5 = '$pass' AND email = '$email'";
$res=mysql_query($dati);
if(!$res){
echo"no";
}
$num_rows = mysql_num_rows($res);
if($num_rows==true){
$_SESSION['user']=$email;
$_SESSION['pass']=$pass;
echo "0";
}else{
echo"1";
}
?>
infine la pagina protetta (in teoria)
<?php
$nome=$_SESSION['user'];
echo "$nome";
echo "$pass";
?>
<head>
</head>
<body>
<form action="esci.php" method="post">
<input type="submit" value="esci" />
</form>
</body>
Il problema e che non mi vede la sessione e non scrive il valore qualcuno riesce ad iutarmi?
e solo con le sessioni percherche i cokkie funzionano ma le sessioni sono piu adatte