Skatecrazy1 Posted September 22, 2006 Share Posted September 22, 2006 Okay so I have this file set up with my log in function:[code]<?phpclass 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]<?phpinclude('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. Quote Link to comment Share on other sites More sharing options...
trq Posted September 22, 2006 Share Posted September 22, 2006 Variables within a class need to be referenced using $this->variable syntax. Eg;[code=php:0]if ((!$this->username) or (!$this->password)) {[/code] Quote Link to comment Share on other sites More sharing options...
Skatecrazy1 Posted September 22, 2006 Author Share Posted September 22, 2006 so in my case$authenticate->variable?or is the $this thing like universal...? Quote Link to comment Share on other sites More sharing options...
trq Posted September 22, 2006 Share Posted September 22, 2006 No... You need to use $this. Maybe you should take a look at the [url=http://php.net/oop]manual[/url] for some class examples. Id'e also try and avoid putting any output within a class, its pretty bad practice. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.