Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    10

    [Member area] Non effettua il login

    Salve a tutti,
    ho scaricato lo script member area dalla sezione free per creare una sezione (non visibile a tutti) per accedere ad una area riservata.
    Ho adattato lo script alla mia pagina web, e fatto tutti i collegamenti, ma non effettua il login e benchè effettui la registrazione, quando mi loggo mi dice che nome utente o password sono errati.
    E, altra cosa: benchè m'iscriva di continuo conta sempre 3 utenti (quelli creati in locale)

    questo è il codice della pagina per effettuare il login (la pagina principale, index.php)
    codice:
    <?php
    session_start(); // Maintain session state
    header("Cache-control: private");	// Fixes IE6's back button problem.
    
    // Are we logged in, or logging in?
    if(@$_SESSION['user']) header("location: login.php");
    else{
    ?>
    <html>
    <head>
    
    
    </head>
    <body onload = "document.getElementById('user').focus();">
    
    <form method = "post" action = "login.php">
    <table width="186" border = "0" align = "center" cellpadding = "10" cellspacing = "0" style = "height: 20%;">
    <tr>
    		<td colspan = "3" valign = "bottom">
    			<span class = "bold">Area riservata</span>	
    
    			<?php
    			// Get user count
    			$file = file("users.php");
    			$userCount = 0;
    
    			for($line = 0; $line < sizeof($file); $line++){
    				if("//" != substr($file[$line], 0, 2)) $userCount++;
    			}
    			?>
    			<span class = "hilight">ci sono</span> <span class = "bold hilight"><?php print $userCount; ?></span> <span class = "hilight">utenti registrati!</span>
    		</td>
    	</tr>
    	<tr>
    		<td colspan = "3" height = "5%">
    			<a href = "addUser.php">signup</a> 
    			<?php
    			// Check if we need to add a message
    			if(@$_GET["fail"]) echo "| <span class = 'alert'>Incorrect username or password</span>";
    			elseif(@$_GET["logout"]) echo "| <span class = 'alert'>Successfully logged out</span>";
    			elseif(@$_GET["new"]) echo "| <span class = 'alert'>Successfully registered</span>";
    			?>
    		</td>
    	</tr>
    	<tr>
    		<td width = "66" height = "10" valign = "bottom">
    			username:		</td>
      <td width = "144" height = "10" valign = "bottom">
    		<input type = "text" id = "user" name = "user" style = "width: 80%" class = "text" tabindex = "1">
    		</td>
    <td rowspan = "2" width = "16" height = "16" align = "right" valign = "bottom">
    			<input type = "image" src = "next.gif" width  = "16" height = "16" name = "submit" alt = "arrow pointing right: next" tabindex = "3">
    		</td>
    	</tr>
    	<tr>
    		<td width = "66" height = "10" valign = "bottom">
    			password:		</td>
      <td width = "144" height = "10" valign = "bottom">
    		<input type = "password" name = "pass" style = "width: 80%" class = "text" tabindex = "2">
    		</td>
    	</tr>
    	<tr>
    	</tr>
    </table>
    </form>
    </body>
    </html>
    <?php
    }
    ?>
    questa è la pagina che richiama, la login.php

    codice:
    <?php
    session_start(); // Maintain session state
    header("Cache-control: private");	// Fixes IE6's back button problem.
    
    // Redirect if not logging in
    if(!@$_POST['user'] && !@$_SESSION['user']) header("location: index.php");
    else{
    	if(@$_SESSION['user']){
    		@include("userarea.php");
    	}
    	else{
    		// Get the posted username and password
    		$user = strtolower($_POST['user']);
    		$pass = $_POST['pass'];
    
    		// Include the flat-file
    		$file = file("users.php") or die("Problem getting the user details flat-file [users.php]");
    
    		// Get the size of file
    		$totalLines = sizeof($file);
    
    		// Get the users details line by line
    		$line = 0;
    		$match = 0;
    		do{
    			// Check the line isn't a comment
    			if("//" != substr($file[$line], 0, 2)){
    				// Break our records up
    				@list($username, $password, $permission, $email, $url, $dob, $location, $joined) = explode("<del>", $file[$line]);
    
    				// Check the username and passwords match
    				if((strtolower($user) == strtolower($username)) && (md5($pass) == $password)) $match = 1;
    				else $match = 0;
    			}
    
    			// Exit loop if match found
    			if($match) break;
    			
    			// Increment line count
    			$line++;
    		} while($line < $totalLines);
    
    		// Include the file or send them back
    		if($match){
    			$_SESSION["user"] = $user;
    			$_SESSION["pass"] = $pass;
    			$_SESSION["permission"] = $permission;
    			$_SESSION["email"] = $email;
    			$_SESSION["url"] = $url;
    			$_SESSION["dob"] = $dob;
    			$_SESSION["location"] = $location;
    			$_SESSION["joined"] = $joined;
    			
    			// Refresh page
    			header("location: ". $_SERVER['PHP_SELF']);
    		}
    		else header("location: index.php?fail=1");
    	}
    }
    ?>
    help me please

  2. #2

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    10
    scusa, che c'entra l'header location?
    il redirect lo fa, ma non registra gli utenti, quindi il login è nullo.

    c'è qualcuno che possa dare una lettura veloce al codice e dirmi se c'è qualcosa che non va perfavore?

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    10
    up
    mi aiutate perfavore??

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 © 2024 vBulletin Solutions, Inc. All rights reserved.