Un Evento Unico. 5 Sale. 27 Interventi. SEO, SOCIAL, E-Commerce, Mobile, Turismo.
CLICCA QUI e SCOPRI DI PIù X Chiudi
 
Forum GT: Condividiamo idee e conoscenza Forum GT: Condividiamo idee e conoscenza


Condividi questo contenuto nei Social Network:
Ti stiamo aspettando: Registrati subito e gratis. Entra a far parte di una delle comunità più attive in Italia. Se hai dimenticato i tuoi dati li puoi recuperare subito.


Vai indietro   Forum per Webmaster: Condividiamo Idee e Conoscenza > Sviluppo e Gestione siti web > Php - Mysql
Benvenuto! Forum Regole FAQ Lista utenti Calendario Segna come letti


Rispondi
 
LinkBack Strumenti di discussione
Vecchio 13-07-11, 14:57   #1 (permalink)
User
 
Data di registrazione: Feb 2011
Ubicazione: Bari
Messaggi: 10
set-cookie

ciao a tutti,
ho creato questa area di login funzionante con la pagina di registrazione ed ovviamente mysql. il problema è che vorrei trovare il tag cookie per tener loggato un utente, ad esempio per...........una settimana. qualcuno mi puo aiutare? grazie.
questa è la pagina di login:

<form id="form1" name="login" method="POST" action="index.php">
<fieldset>
<legend><strong>Login</strong></legend>
<p>
<label for="username"><strong>Username</strong></label>
<input type="text" name="username" id="username" />
<label for="password"><strong><br />
<br />
Password</strong></label>
<input type="password" name="password" id="password" />
</p>
<p>
<label for="invio"></label>
<input type="submit" name="invio" id="invio" value="Accedi" />
</p>
<p><a href="registrazione.php">Registrami</a><br />
</p>
<?php require_once('Connections/connectdw.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();

}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "home.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connectdw, $connectdw);

$LoginRS__query=sprintf("SELECT username, password FROM utenti WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $connectdw) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}

//immagazzinano le informazioni dell'utente in un array

$var_session["username"]=$row["username"];
$var_session["password"]=$row["password"];

//setto la durata del cookies a una settimana
$time_cookie=3600*24*7;
setcookie("session", $var_session["username"].'_&&_'.$var_session["password"], time()+$time_cookie);

header("Location: " . $MM_redirectLoginSuccess );
}
else {

echo "Non hai inserito i dati corretti. Riprova.";

}
}
?><br />
</fieldset>
</form>
Air93 non in linea   Rispondi citando
Rispondi


Strumenti di discussione

Regole di scrittura
Non puoi postare nuove discussioni
Non puoi rispondere alle discussioni
Non puoi allegare file
Non puoi editare i tuoi post

BB code is Attivo
smilies è Attivo
[IMG] il codice è Attivo
Il codice HTML è Disattivato
Trackbacks are Attivo
Pingbacks are Attivo
Refbacks are Disattivato
Vai al forum



Tutti gli orari sono GMT +3. Attualmente sono le 15:34.




Forum GT - © 2004-2009 GT idea S.r.l P.iva 02418200800 - Privacy/Disclaimer

SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.