Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Oroblema loggin php

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    10

    Oroblema loggin php

    Ciao a tutti come da titolo il mio problema sta nel loggin nel mio sito mi spiego:
    Quando io mi loggo tutto bene......però dopo 1 minuto che sono collegato non so se scade la sessione o il cookie e mi fa riloggare .
    Credo di aver settato correttamente il form di loggin nella pagina sottostante
    codice:
    <?php
    include_once("include/config.php");
    include_once("include/auth.lib.php");
    
    list($status, $user) = auth_get_status();
    
    if($status == AUTH_LOGGED & auth_get_option("TRANSICTION METHOD") == AUTH_USE_COOKIE){
    	$link = "?uid=".$_GET['uid'];
    }else	$link = '';
    ?>
    <html>
    	<head>
    		<title>Stronzatebook</title>
    	<link href="/stili.css" rel="stylesheet" type="text/css">
    	</head>
    	<body>
    	<table height="446" border="0" align="center">
    	  <tr>
    	    <td width="118" rowspan="3"></td>
    	    <td width="752" align="center">[img]/immagini/server-d-prova.jpg[/img]</td>
    	    <td width="91" rowspan="3"></td>
          </tr>
    	  <tr>
    	    <td align="center"><table border="0">
    	      <tr>
    	        <td>
    
    
    	          <?php include('menu.html');?>
                </td>
              </tr>
            </table></td>
          </tr>
    	  <tr>
    	    <td></td>
          </tr>
    	  <tr>
    	    <td height="207"></td>
    	    <td><div align="center">
    
    
              <?php
    		switch($status){
    			case AUTH_LOGGED:
    			?>
              Sei loggato con il nome di 
              <?=$user["name"];?> 
              Logout
              <?php
    			break;
    			case AUTH_NOT_LOGGED:
    			?>
              </p>
              <form action="login.php<?=$link?>" method="post">
              <table cellspacing="2">
    				<tr>
    					<td class="loggin">Nome Utente:</td>
    					<td><input type="text" name="uname"></td>
    				</tr>
    				<tr>
    					<td class="loggin">Password:</td>
    					<td><input type="password" name="passw"></td>
    				</tr>
    				<tr>
    					<td colspan="2"><input name="action" type="submit" class="loggin" value="Login"></td>
    				</tr>
    			</table>
    		</form>
    		<?php
    			break;
    		}
    		?>
    	</div></td>
    	    <td></td>
          </tr>
    	  <tr>
    	    <td></td>
    	    <td></td>
    	    <td></td>
          </tr>
        </table>
    	
    
    </p>
        </body>
    </html>
    e anke nello script di loggin sottostante il tempo in cui io dovrei essere connesso dovrebbe essere 3600 secondi = 1ora dopodichè dovrebbe automaticamente sloggare. Il problema e che non rimane loggato nemmeno 1 Minuto
    login.php
    codice:
    <?php
    include_once("include/config.php");
    include_once("include/auth.lib.php");
    
    list($status, $user) = auth_get_status();
    
    if($status == AUTH_NOT_LOGGED){
    	$uname = strtolower(trim($_POST['uname']));
    	$passw = strtolower(trim($_POST['passw']));
    
    	if($uname == "" or $passw == ""){
    		$status = AUTH_INVALID_PARAMS;
    	}else{
    		list($status, $user) = auth_login($uname, $passw);
    		if(!is_null($user)){
    			list($status, $uid) = auth_register_session($user);
    		}
    	}
    }
    
    switch($status){
    	case AUTH_LOGGED:
    		header("Refresh: 5;URL=index.php");
    		echo '<div align="center">Sei gia connesso ... attendi il reindirizzamento</div>';
    	break;
    	case AUTH_INVALID_PARAMS:
    		header("Refresh: 5;URL=index.php");
    		echo '<div align="center">Hai inserito dati non corretti ... attendi il reindirizzamento</div>';
    	break;
    	case AUTH_LOGEDD_IN:
    		switch(auth_get_option("TRANSICTION METHOD")){
    			case AUTH_USE_LINK:
    				header("Refresh: 5;URL=index.php?uid=".$uid);
    			break;
    			case AUTH_USE_COOKIE:
    				header("Refresh: 5;URL=index.php");
    				setcookie('uid', $uid, time()+3600);
    			break;
    			case AUTH_USE_SESSION:
    				header("Refresh: 5;URL=index.php");
    				$_SESSION['uid'] = $uid;
    			break;
    		}
    		echo '<div align="center">Ciao '.$user['name'].' ... attendi il reindirizzamento</div>';
    	break;
    	case AUTH_FAILED:
    		header("Refresh: 5;URL=index.php");
    		echo '<div align="center">Fallimento durante il tentativo di connessione ... attendi il reindirizzamento</div>';
    	break;
    }
    ?>
    infine non cadisco a cosa possa servire il <?=$link?> nel collegamento


    <td>Prima Pagina (pubblica)</td>

    Vi prego aiutatemi non capisco come possa accadere tutto cio

    Un mille grazie in anticipo 1000

  2. #2
    sto leggendo un po il tuo codice ma... l'hai scritto tu o stai lavorando su un sito già fatto o su dei template?

  3. #3
    secondo me l'errore è nella definizione della variabile $link perché da quello che ho capito viene usato il passaggio via GET quando il TRANSICTION_METHOD è LINK non COOKIE...

    quindi:
    Codice PHP:
    if($status == AUTH_LOGGED auth_get_option("TRANSICTION METHOD") == AUTH_USE_COOKIE /* qui dovresti  metterci AUTH_USE_LINK */){
        
    $link "?uid=".$_GET['uid'];
    }else    
    $link ''
    prova e dimmi

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    10
    ho provato a usare le sessioni cosi

    codice:
    if($status == AUTH_LOGGED & auth_get_option("TRANSICTION METHOD") == AUTH_USE_SESSION ){ 
        $link = "?uid=".$_GET['uid']; 
    }else    $link = '';
    e funziona fin li dato che mi crea le sessioni sul server e poi ho trovato questo

    codice:
    <?php
    $_CONFIG['host'] = "localhost";
    $_CONFIG['user'] = "stronzatebook";
    $_CONFIG['pass'] = "rftglc920613";
    $_CONFIG['dbname'] = "my_stronzatebook";
    
    $_CONFIG['table_sessioni'] = "sessioni";
    $_CONFIG['table_utenti'] = "utenti";
    
    $_CONFIG['expire'] = 60;// questo dovrebbe il tempo della sessione giusto?
    $_CONFIG['regexpire'] = 24; //in ore
    
    $_CONFIG['check_table'] = array(
    	"username" => "check_username",
    	"password" => "check_global",
    	"name" => "check_global",
    	"surname" => "check_global",
    	"indirizzo" => "check_global",
    	"occupazione" => "check_global",
    	"mail" => "check_global"
    );
    
    function check_username($value){
    	global $_CONFIG;
    	
    	$value = trim($value);
    	if($value == "")
    		return "Il campo non può essere lasciato vuoto";
    	$query = mysql_query("
    	SELECT id
    	FROM ".$_CONFIG['table_utenti']."
    	WHERE username='".$value."'");
    	if(mysql_num_rows($query) != 0)
    		return "Nome utente già utilizzato";
    	
    	return true;
    }
    
    function check_global($value){
    	global $_CONFIG;
    	
    	$value = trim($value);
    	if($value == "")
    		return "Il campo non può essere lasciato vuoto";
    	
    	return true;
    }
    
    
    //--------------
    define('AUTH_LOGGED', 99);
    define('AUTH_NOT_LOGGED', 100);
    
    define('AUTH_USE_COOKIE', 101);
    define('AUTH_USE_LINK', 103);
    define('AUTH_INVALID_PARAMS', 104);
    define('AUTH_LOGEDD_IN', 105);
    define('AUTH_FAILED', 106);
    
    define('REG_ERRORS', 107);
    define('REG_SUCCESS', 108);
    define('REG_FAILED', 109);
    
    $conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione');
    mysql_select_db($_CONFIG['dbname']);
    ?>
    ho poi provato a sostituire questo tempo:
    $_CONFIG['expire'] = 60;
    con
    $_CONFIG['expire'] = 10000;
    e rimane collegato di più...

    Però avendo sostituito la dicitura

    codice:
    if($status == AUTH_LOGGED & auth_get_option("TRANSICTION METHOD") == AUTH_USE_SESSION ){ 
        $link = "?uid=".$_GET['uid']; 
    }else    $link = '';
    inserendo le sessioni creerei dei problemi con i cookie???
    e comunque se usassi il passagio dati con i link dovrei tenerli con questo modo?? cioe tenedo la inclusione <?=$link?> ??

    <td>Prima Pagina (pubblica)</td>

    comunque sto lavorando con dei template prelevati dalla gestione utenti con il PHP..

    Ah gia mi dimenticavo :master: :master:

    Posso inserire in questa index
    codice:
    <?php
    include_once("include/config.php");
    include_once("include/auth.lib.php");
    include_once("include/cookie.php");
    
    list($status, $user) = auth_get_status();
    
    if($status == AUTH_LOGGED & auth_get_option("TRANSICTION METHOD") == AUTH_USE_SESSION){
    	$link = "?uid=".$_GET['uid'];
    }else	$link = '';
    ?>
    <html>
    	<head>
    		<title>Stronzatebook</title>
    	<link href="/stili.css" rel="stylesheet" type="text/css">
    	</head>
         <? if(isset($_POST['ricordami'])) {    
             $joined =''.$_POST['username'].'[]'.md5($_POST['password']).'';  
             setcookie($nome_cookie, $joined, time()+$scadenza, $percorso, $dominio);     
        } ?>  
    	<body>
    	<table height="446" border="0" align="center">
    	  <tr>
    	    <td width="118" rowspan="3"></td>
    	    <td width="752" align="center">[img]/immagini/server-d-prova.jpg[/img]</td>
    	    <td width="91" rowspan="3"></td>
          </tr>
    	  <tr>
    	    <td align="center"><table border="0">
    	      <tr>
    	        <td>
    
    
    	          <?php include('frame/menu.html');?>
                </td>
              </tr>
            </table></td>
          </tr>
    	  <tr>
    	    <td></td>
          </tr>
    	  <tr>
    	    <td height="207"></td>
    	    <td><div align="center">
    
    
              <?php
    		switch($status){
    			case AUTH_LOGGED:
    			?>
              Sei loggato con il nome di 
              <?=$user["name"];?> 
              Logout
              <?php
    			break;
    			case AUTH_NOT_LOGGED:
    			?>
              </p>
              <form action="login.php<?=$link?>" method="post">
              <table cellspacing="2">
    				<tr>
    					<td class="loggin">Nome Utente:</td>
    					<td><input type="text" name="uname"></td>
    				</tr>
    				<tr>
    					<td class="loggin">Password:</td>
    					<td><input type="password" name="passw"></td>
    				</tr>
    				<tr>
    				  <td class="loggin">Ricordami</td>
    				  <td><input type="checkbox" name="ricordami[]" value="ON" class="check"></td>
    		    </tr>
    				<tr>
    					<td colspan="2"><input name="action" type="submit" class="loggin" value="Login"></td>
    				</tr>
    			</table>
    		</form>
    		<?php
    			break;
    		}
    		?>
    	</div></td>
    	    <td></td>
          </tr>
    	  <tr>
    	    <td></td>
    	    <td></td>
    	    <td></td>
          </tr>
        </table>
    	
    
    </p>
        </body>
    </html>
    un chebox ricordami o resta collegato anke quando si chiude il browser o finisce la sessione??

    Grazie di nuovo in anticipo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.