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)
questa è la pagina che richiama, la login.phpcodice:<?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 } ?>
help me pleasecodice:<?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"); } } ?>![]()


Rispondi quotando