<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Script per login che non effettua il login]]></title><description><![CDATA[<p dir="auto">Salve a tutti,<br />
ho un problema con uno script php che protegge attraverso il login una sezione del sito.<br />
Lo script è composto di 8 file più il css: il problema è che lo script non effettua il login, ossia quando provo a registrarmi, mi dice che l'iscrizione è avvenuta, e reindizza alla pagina di login, metto username e password ma non accede, mi dice che i dati sono incorretti.</p>
<p dir="auto">questa è la pagina di login, la index.php</p>
<pre><code>&lt;?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{
?&gt;
&lt;html&gt;
&lt;head&gt;

&lt;link rel = "stylesheet" type = "text/css" href = "style.css"&gt;
&lt;title&gt;members area: mike holloway&lt;/title&gt;
&lt;/head&gt;
&lt;body onload = "document.getElementById('user').focus();"&gt;

&lt;form method = "post" action = "login.php"&gt;
&lt;table border = "0" cellspacing = "0" cellpadding = "10" width = "50%" align = "center" style = "height: 100%;"&gt;
    &lt;tr&gt;
        &lt;td colspan = "3" valign = "bottom"&gt;
            &lt;span class = "bold"&gt;members area, v: 3.0&lt;/span&gt;    &lt;br&gt;
            &lt;?php
            // Get user count
            $file = file("users.php");
            $userCount = 0;

            for($line = 0; $line &lt; sizeof($file); $line++){
                if("//" != substr($file[$line], 0, 2)) $userCount++;
            }
            ?&gt;
            &lt;span class = "hilight"&gt;we have&lt;/span&gt; &lt;span class = "bold hilight"&gt;&lt;?php print $userCount; ?&gt;&lt;/span&gt; &lt;span class = "hilight"&gt;members and growing!&lt;/span&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan = "3" height = "5%"&gt;
            &lt;a href = "addUser.php"&gt;signup&lt;/a&gt; 
            &lt;?php
            // Check if we need to add a message
            if(@$_GET["fail"]) echo "| &lt;span class = 'alert'&gt;Incorrect username or password&lt;/span&gt;";
            elseif(@$_GET["logout"]) echo "| &lt;span class = 'alert'&gt;Successfully logged out&lt;/span&gt;";
            elseif(@$_GET["new"]) echo "| &lt;span class = 'alert'&gt;Successfully registered&lt;/span&gt;";
            ?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td width = "30%" height = "10" valign = "bottom"&gt;
            username:
        &lt;/td&gt;
        &lt;td width = "70%" height = "10" valign = "bottom"&gt;
            &lt;input type = "text" id = "user" name = "user" style = "width: 80%" class = "text" tabindex = "1"&gt;
        &lt;/td&gt;
        &lt;td rowspan = "2" width = "16" height = "16" align = "right" valign = "bottom"&gt;
            &lt;input type = "image" src = "next.gif" width  = "16" height = "16" name = "submit" alt = "arrow pointing right: next" tabindex = "3"&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td width = "30%" height = "10" valign = "bottom"&gt;
            password:
        &lt;/td&gt;
        &lt;td width = "70%" height = "10" valign = "bottom"&gt;
            &lt;input type = "password" name = "pass" style = "width: 80%" class = "text" tabindex = "2"&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan = "3" valign = "top" style = "color: #cccccc;"&gt;
            freeware by: &lt;a href = "mikeholloway.co.uk" target = "_blank"&gt;mike holloway&lt;a/&gt;, 2003.
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
}
?&gt;
</code></pre>
<p dir="auto">questa la pagina che richiama, la login.php</p>
<pre><code>&lt;?php
session_start(); // Maintain session state
header("Cache-control: private");    // Fixes IE6's back button problem.

// Redirect if not logging in
if(!@$_POST['user'] &amp;&amp; !@$_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("&lt;del&gt;", $file[$line]);

                // Check the username and passwords match
                if((strtolower($user) == strtolower($username)) &amp;&amp; (md5($pass) == $password)) $match = 1;
                else $match = 0;
            }

            // Exit loop if match found
            if($match) break;
            
            // Increment line count
            $line++;
        } while($line &lt; $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");
    }
}
?&gt;
</code></pre>
<p dir="auto">mi aiutate perfavore?<br />
grazie fin d'ora</p>
]]></description><link>https://dev.connect.gt/topic/70067/script-per-login-che-non-effettua-il-login</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 04:53:50 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/70067.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Apr 2008 20:38:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Script per login che non effettua il login on Tue, 29 Apr 2008 20:28:52 GMT]]></title><description><![CDATA[<p dir="auto">up<br />
c'è qualcuno che può darmi una mano?</p>
]]></description><link>https://dev.connect.gt/post/707963</link><guid isPermaLink="true">https://dev.connect.gt/post/707963</guid><dc:creator><![CDATA[tracy]]></dc:creator><pubDate>Tue, 29 Apr 2008 20:28:52 GMT</pubDate></item></channel></rss>