Canadiengland Posted August 22, 2007 Share Posted August 22, 2007 for some reason, when i try to register a new account to my game it says "cannot register user". ive searched for this in my php files but cannot find it. also, when i try to log in to my game, it works and displays the new page. but the moment i refresh it says i am not logged in again. is this a problem with my cookies? does anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/ Share on other sites More sharing options...
nathanmaxsonadil Posted August 22, 2007 Share Posted August 22, 2007 maybe you can post some code? Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330467 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 <html> <head> <style type="text/css"> <!-- body { background-color: #110f0c; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> </head> <body> <font color="#990000"> <link rel="stylesheet" href="loginstyle.css" type="text/css"> <?php include "connect.php"; if (isset($_POST['submit'])) // name of submit button { $player=$_POST['player']; $password=$_POST['password']; $player=strip_tags($player); $password=md5($password); $query = "select * from km_users where playername='$player' and password='$password' and validated='1'"; $result = mysql_query($query) or die("No te Gusta") ; $result2=mysql_fetch_array($result); if($result2) { session_start(); $_SESSION['player']=$player; print "logged in successfully<br><br>"; print "<A href='index.php'>Go to Admin Panel</a>"; } else { echo "<center><table width='750' height='144'><td>"; include 'top.php'; // top echo "</td></table>"; echo "<table width='750' height='30'><td width='750'><center><img src='images/statusbar.jpg'>"; echo "<center><br><table class='maintable' width='750' height='500'>"; echo "<td>"; print "<center>Wrong username or password or non-activated account."; print "<center><A href='index.php'>Back</a></center>"; echo "</td></table>"; } } ?> </body> </html> authenticate.php <?php parse_str("$QUERY_STRING"); $db = mysql_connect("localhost", "root", "stars") or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db("monster",$db)) die("No database selected."); if(!get_magic_quotes_gpc()) { $_GET = array_map('mysql_real_escape_string', $_GET); $_POST = array_map('mysql_real_escape_string', $_POST); $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE); } else { $_GET = array_map('stripslashes', $_GET); $_POST = array_map('stripslashes', $_POST); $_COOKIE = array_map('stripslashes', $_COOKIE); $_GET = array_map('mysql_real_escape_string', $_GET); $_POST = array_map('mysql_real_escape_string', $_POST); $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE); } ?> connect.php i know its written horribly but it worked before i stopped workin on it for a while Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330475 Share on other sites More sharing options...
nathanmaxsonadil Posted August 22, 2007 Share Posted August 22, 2007 you need to put session_start(); on the top of the page Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330490 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 didnt work. i dont think thats the case, i have that on the index pages and what not Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330563 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Share Posted August 22, 2007 No, you have to put session_start(); as the first PHP line. Also, I'm not sure about $result2 = mysql_fetch_array($result); Normally people use that as a loop. In your case, I'm not sure what's it for. Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330569 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 like i said, i know its written poorly but w.e it worked before, now it just stopped all of a sudden i dont remember changing anything Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330584 Share on other sites More sharing options...
teng84 Posted August 22, 2007 Share Posted August 22, 2007 maybe its because the session set to expire on that given time or you dont set the session if you really use it Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330591 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 no clue it worked yesterday but now its not haha i didnt alter anything Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330595 Share on other sites More sharing options...
teng84 Posted August 22, 2007 Share Posted August 22, 2007 loooooooooook if($result2) { session_start(); $_SESSION['player']=$player; print "logged in successfully<br><br>"; print "<A href='index.php'>Go to Admin Panel</a>"; } you declare the session start at the middle without the ob_start but you dont get an error. now what i mean is that the if statement is not satisfied Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330596 Share on other sites More sharing options...
beboo002 Posted August 22, 2007 Share Posted August 22, 2007 put ob_start(); right above session function. it may help u hope so Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330598 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 tried all of which didnt help Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330602 Share on other sites More sharing options...
beboo002 Posted August 22, 2007 Share Posted August 22, 2007 use this code $_SESSION['player'] = mysql_result($result, 0, 'player'); insted of $_SESSION['player']=$player; and echo the player name to see session value are pass r not. Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330607 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 GAH SO FRUSTRATING. i echoed the player name and it DOES know ive logged in but BAM as soon as i refresh im not Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330672 Share on other sites More sharing options...
Canadiengland Posted August 22, 2007 Author Share Posted August 22, 2007 could this simply be a problem with my cookies / intranet? Quote Link to comment https://forums.phpfreaks.com/topic/66078-connecting-registering/#findComment-330674 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.