Jump to content

OOP Problems with Login Handling class


Skatecrazy1

Recommended Posts

Okay so I have this file set up with my log in function:

[code]
<?php

class LogIn {

var $username;
var $password;
var $referer;
    function siteLogin()
    {
        // connect to the server
        $conn = @mysql_connect("this", "is", "private")
        or die('Could not connect to mySQL.');
        if ((!$username) or (!$password)) {
            header("location:$referer");
            exit();
        }
        // select a database
        $rs = mysql_select_db("snapskate", $conn);
        // put up the mysql query
        $sql = "select * from users where username=\"$username\" and password=\"$password\"";
        // now put the query execution in a variable so we can use it later
        $rs = @mysql_query($sql, $conn);
        // now see how many rows come up with a match.
        $num = mysql_num_rows($rs);
        // if it came up as one or more, log the user in
        if ($num != null) {
            setcookie('loggedin', '1', time() + 36000);
            setcookie('username', $username, time() + 36000);
            $msg = "<table cellpadding=\"20\">";
            $msg .= "<tr><td class=\"inout\" valign=\"middle\" align=\"center\">";
            $msg .= "Thank You.  You are now logged in as $username. <br />You are now being transferred.<br /><br />";
            $msg .= "<a href=\"http://www.snapskate.com/index.php\">Click here if you do not wish to wait</a>";
            $msg .= "</tr></td></table>";
            echo($msg);
            echo("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"2;URL=http://www.snapskate.com/\">");
        } else {
            sleep(2);
            header("location:$referer");
            exit();
        }
    }
}

?>
[/code]

and this file (authenticate.php) that used to use all of that same code is here, with the updates:

[code]
<?php
include('funcs.php');

$authenticate = &New LogIn;

$authenticate->username = $_POST['username'];
$authenticate->password = $_POST['password'];
$authenticate->referer = $_SERVER['HTTP_REFERER'];

$authenticate->siteLogin();
?>

<link rel="stylesheet" type="text/css" href="
<?php
$style = $_COOKIE['style'];
if(isset($style)){
  echo $style;
} else {
echo("css/style.css");
}
?>
" media="screen" />
[/code]

now usually, as you can see, when the user gets logged in it says "you're now logged in, please wait while we transfer you," or some crap like that.  I just get a white screen on this, and I doublecheck my cookies as well to see if it worked or not and sure enough, no cookie from my login script.  just wondering if it's because i have some variables mixed up or if it simply isn't possible.  thanks in advance for any help.
Link to comment
https://forums.phpfreaks.com/topic/21606-oop-problems-with-login-handling-class/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.