Pi_Mastuh Posted April 15, 2007 Share Posted April 15, 2007 I went to my site today and logged in, and when it went to the homepage I got the Error you must be logged in to be here. It all of a sudden won't log users in and I can't figure out why. When the user puts in the user name and password it goes to this page: <? include ("config2.php"); if ((!$preuserName) || (!$preuserPassword)) { header("Location:http://www.$domain/demo/login.php"); exit; } else { $db = mysql_select_db($db_name, $connection) or die("Couldn't select database2."); $sql = "SELECT * FROM chibifriends WHERE preuserName =\"$preuserName\" AND preuserPassword = \"$preuserPassword\" "; $result = mysql_query($sql,$connection) or die("Couldn't execute query."); $query_data = mysql_fetch_array($result); $preuserID = $query_data['preuserID']; $preuserAge = $query_data['preuserAge']; $cimage = $query_data['image']; $userstatus = $query_data['userstatus']; $num = mysql_num_rows($result); if ($num != 0) { session_start(); session_register('preuserName'); session_register('preuserID'); session_register('cimage'); session_register('preuserAge'); session_register('userstatus'); $session=session_id(); setcookie("NetPetzpreuserID", "$preuserID", time()+60*60*24*100, "/"); setcookie("NetPetzpreuserName", "$preuserName", time()+60*60*24*100, "/"); $domain = GetHostByName($REMOTE_ADDR); header("Location: ../home.php"); exit; } } ?> Then it redirects to this page: <html> <head> <meta http-equiv="Content-Language" content="en-us"> <TITLE>Welcome to Net-Petz! ~ Home</TITLE> <script language="JavaScript" fptype="dynamicanimation"> <!-- function dynAnimation() {} function clickSwapImg() {} //--> </script> <script language="JavaScript1.2" fptype="dynamicanimation" src="animate.js"> </script></head> <? if ($preuserID == 0) { print"<p align=center>You need to login again. Please <a href=../login.php>click here</a>."; die; } ?> <body onLoad="dynAnimation()"> <div align="center"> <table border="0" cellspacing="1" bordercolor="#000000" width="34%" id="AutoNumber1" height="100" align="left"> <tr> <td width="100%" height="90" colspan="2" align="center" valign="top" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF"> <p> <img border="0" src="../sidebarr.jpg" width="1024" height="91"></td> </tr> <tr> <td width="12%" height="747" align="center" valign="top" bordercolor="#FFFFFF"> <p> <img border="0" src="titleexplore.jpg" width="130" height="22"><br> <a onMouseOver="document['fpAnimswapImgFP21'].imgRolln=document['fpAnimswapImgFP21'].src;document['fpAnimswapImgFP21'].src=document['fpAnimswapImgFP21'].lowsrc;" onMouseOut="document['fpAnimswapImgFP21'].src=document['fpAnimswapImgFP21'].imgRolln" href="netlandia.php"> <img border="0" src="world1.jpg" id="fpAnimswapImgFP21" name="fpAnimswapImgFP21" dynamicanimation="fpAnimswapImgFP21" lowsrc="world2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP22'].imgRolln=document['fpAnimswapImgFP22'].src;document['fpAnimswapImgFP22'].src=document['fpAnimswapImgFP22'].lowsrc;" onMouseOut="document['fpAnimswapImgFP22'].src=document['fpAnimswapImgFP22'].imgRolln" href="city.php"> <img border="0" src="market1.jpg" id="fpAnimswapImgFP22" name="fpAnimswapImgFP22" dynamicanimation="fpAnimswapImgFP22" lowsrc="market2.jpg" width="130" height="22"></a><br> <img border="0" src="titlefun.jpg" width="130" height="22"><br> <a onMouseOver="document['fpAnimswapImgFP23'].imgRolln=document['fpAnimswapImgFP23'].src;document['fpAnimswapImgFP23'].src=document['fpAnimswapImgFP23'].lowsrc;" onMouseOut="document['fpAnimswapImgFP23'].src=document['fpAnimswapImgFP23'].imgRolln" href="games.php"> <img border="0" src="games1.jpg" id="fpAnimswapImgFP23" name="fpAnimswapImgFP23" dynamicanimation="fpAnimswapImgFP23" lowsrc="games2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP24'].imgRolln=document['fpAnimswapImgFP24'].src;document['fpAnimswapImgFP24'].src=document['fpAnimswapImgFP24'].lowsrc;" onMouseOut="document['fpAnimswapImgFP24'].src=document['fpAnimswapImgFP24'].imgRolln" href="messageboard.php"> <img border="0" src="boards1.jpg" id="fpAnimswapImgFP24" name="fpAnimswapImgFP24" dynamicanimation="fpAnimswapImgFP24" lowsrc="boards2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP25'].imgRolln=document['fpAnimswapImgFP25'].src;document['fpAnimswapImgFP25'].src=document['fpAnimswapImgFP25'].lowsrc;" onMouseOut="document['fpAnimswapImgFP25'].src=document['fpAnimswapImgFP25'].imgRolln" href="inbox.php"> <img border="0" src="../images/Sidebar%20&%20Layout/mail1.jpg" id="fpAnimswapImgFP25" name="fpAnimswapImgFP25" dynamicanimation="fpAnimswapImgFP25" lowsrc="../images/Sidebar%20&%20Layout/mail2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP26'].imgRolln=document['fpAnimswapImgFP26'].src;document['fpAnimswapImgFP26'].src=document['fpAnimswapImgFP26'].lowsrc;" onMouseOut="document['fpAnimswapImgFP26'].src=document['fpAnimswapImgFP26'].imgRolln" href="stuff.php"> <img border="0" src="stuff1.jpg" id="fpAnimswapImgFP26" name="fpAnimswapImgFP26" dynamicanimation="fpAnimswapImgFP26" lowsrc="stuff2.jpg" width="130" height="22"></a><br> <img border="0" src="titlemisc.jpg" width="130" height="22"><br> <a onMouseOver="document['fpAnimswapImgFP27'].imgRolln=document['fpAnimswapImgFP27'].src;document['fpAnimswapImgFP27'].src=document['fpAnimswapImgFP27'].lowsrc;" onMouseOut="document['fpAnimswapImgFP27'].src=document['fpAnimswapImgFP27'].imgRolln" href="login.php"> <img border="0" src="in1.jpg" id="fpAnimswapImgFP27" name="fpAnimswapImgFP27" dynamicanimation="fpAnimswapImgFP27" lowsrc="in2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP28'].imgRolln=document['fpAnimswapImgFP28'].src;document['fpAnimswapImgFP28'].src=document['fpAnimswapImgFP28'].lowsrc;" onMouseOut="document['fpAnimswapImgFP28'].src=document['fpAnimswapImgFP28'].imgRolln" href="logout.php"> <img border="0" src="out1.jpg" id="fpAnimswapImgFP28" name="fpAnimswapImgFP28" dynamicanimation="fpAnimswapImgFP28" lowsrc="out2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP29'].imgRolln=document['fpAnimswapImgFP29'].src;document['fpAnimswapImgFP29'].src=document['fpAnimswapImgFP29'].lowsrc;" onMouseOut="document['fpAnimswapImgFP29'].src=document['fpAnimswapImgFP29'].imgRolln" href="help.php"> <img border="0" src="help1.jpg" id="fpAnimswapImgFP29" name="fpAnimswapImgFP29" dynamicanimation="fpAnimswapImgFP29" lowsrc="help2.jpg" width="130" height="22"></a><br> <a onMouseOver="document['fpAnimswapImgFP30'].imgRolln=document['fpAnimswapImgFP30'].src;document['fpAnimswapImgFP30'].src=document['fpAnimswapImgFP30'].lowsrc;" onMouseOut="document['fpAnimswapImgFP30'].src=document['fpAnimswapImgFP30'].imgRolln" href="contact.php"> <img border="0" src="contact1.jpg" id="fpAnimswapImgFP30" name="fpAnimswapImgFP30" dynamicanimation="fpAnimswapImgFP30" lowsrc="contact2.jpg" width="130" height="22"></a></p> <div align="center" style="width: 130; height: 176"> <center> <table border="3" cellspacing="1" bordercolor="#000099" width="100%" id="AutoNumber2" height="253"> <tr> <td width="100%" height="126" align="center" bordercolor="#000099"> <font color="#000099"><? print "Hi $preuserName!"; ?></font></b><br> <b> <font color="#000099"><? print "$points Net-Pointz."; ?><? include ("secure/unread.php"); ?></font></td> </tr> <tr> <td width="100%" height="127" align="center" bordercolor="#000099"> <a href="mypets.php" style="text-decoration: none" dynamicanimation="fpAnimformatRolloverFP1" fprolloverstyle="color: #FF0000; text-decoration: overline underline; font-weight: bold" onMouseOver="rollIn(this)" onMouseOut="rollOut(this)" language="Javascript1.2">My Petz</a><br> <a href="myitems.php" style="text-decoration: none" dynamicanimation="fpAnimformatRolloverFP1" fprolloverstyle="color: #FF0000; text-decoration: overline underline; font-weight: bold" onMouseOver="rollIn(this)" onMouseOut="rollOut(this)" language="Javascript1.2">My Inventory</a></td> </tr> </table> </center> </div> <p><br> <p> <br> </td> <td width="88%" height="374" align="center" valign="top"> <table border="4" cellspacing="1" width="67%" id="AutoNumber3" bordercolorlight="#000099" bordercolordark="#000099"> <tr> <td width="100%" bordercolorlight="#000099" bordercolordark="#000099"> <img border="0" src="Welcome%20logo.gif" width="618" height="44"></td> </tr> </table><br><br> <table border="6" cellspacing="1" width="100%" id="AutoNumber4" height="383" bordercolor="#000099"> <tr> <td width="50%" height="1" valign="top" bordercolor="#000099"> <p align="center"><font size="5" face="Comic Sans MS" color="#000099"> Links</font></td> <td width="50%" height="12" rowspan="6"> <table border="4" cellspacing="1" width="100%" id="AutoNumber5" height="394" bordercolor="#000099"> <tr> <td width="100%" height="19"> <p align="center"><font size="5" face="Comic Sans MS" color="#000099"> News</font></td> </tr> <tr> <td width="100%"> <p align="center"><u><b>29th of the Month of the Worfoli ~ Lynsey's gone! </b></u></p> <p align="center">Hello, I'll be out of town for a week, that means no updates nor anything pretty much. Please everyone be good because I won't be here to freeze users or anything. </p> <p align="center">~Lynsey</p></td> </tr> </table> </td> </tr> <tr> <td width="50%" height="20" valign="top" bordercolor="#000099"> <p align="center"> <font face="Andy" size="4"> <a href="calendar.php" dynamicanimation="fpAnimformatRolloverFP1" fprolloverstyle="color: #FF0000; text-decoration: overline underline; font-weight: bold" onMouseOver="rollIn(this)" onMouseOut="rollOut(this)" language="Javascript1.2" style="text-decoration: none"> The Netlandian Calendar</a></font><br> <a href="lookups.php" style="text-decoration: none" dynamicanimation="fpAnimformatRolloverFP1" fprolloverstyle="color: #FF0000; text-decoration: overline underline; font-weight: bold" onMouseOver="rollIn(this)" onMouseOut="rollOut(this)" language="Javascript1.2"> <font size="4">Lookups</font></a></td> </tr> <tr> <td width="50%" height="11" valign="top" bordercolor="#000099"> <p align="center"><font face="Comic Sans MS" size="5" color="#000099"> Announcments</font></td> </tr> <tr> <td width="50%" height="79" valign="top" bordercolor="#000099"> <p align="center"> <strong> <? $sql = "SELECT count(*) as users FROM chibifriends"; $result1 = mysql_query($sql); $query_data = mysql_fetch_array($result1); $numusers = $query_data['users']; echo "<p align=center>Net-Petz Currently has ".$numusers." Users!"; ?></strong> <p align="center"><b>Net-Petz is best viewed in Internet Explorer and looks bad on Firefox. I'm trying to fix it but I'm new at Firefox. It's best to use Internet Explorer. We have a really cool layout that doesn't work in Firefox ;_;.</b> <p align="center"><a href="helpwanted.php"><img src="helpwanted.gif"></a><br></td> </tr> <tr> <td width="50%" height="13"> <p align="center"><font face="Comic Sans MS" size="5" color="#000099"> Info</font></td> </tr> <tr> <td width="50%" height="92" valign="top"> <p align="center"> <? include ("secure/userstuff.php"); ?> <br> </td> </tr> </table> <div align="left" style="width: 906; height: 734"> </div> <p> <br> </td> </tr> <tr> <td width="12%" height="9" align="center" valign="top" bordercolor="#FFFFFF"> </td> </tr> </table> </div> <? include ("secure/config.php"); include ("secure/dbinfo.php"); include ("secure/petDetails2.php"); $SQL = "SELECT * FROM chibifriendspets WHERE monopetID = '".$_POST['monopetID']."'"; $result = mysql_query($SQL, $connection) or die("Error: ".mysql_error().""); $query_data = mysql_fetch_array($result); $query = "SELECT * FROM chibifriendspets WHERE userID = '$preuserID'"; $result4 = mysql_query($query, $connection); $numberPETS = mysql_num_rows($result4); $query_data = mysql_fetch_array($result4); $monopetID = $query_data['monopetID']; $monopetName = $query_data['monopetName']; $monopetSpecies = $query_data['monopetSpecies']; $monopetDOB = $query_data['monopetDOB']; $i = 0; if ($numberPETS < 1) { print "<CENTER>You don't have any petz!</CENTER>"; } else { while ($numberPETS > $i) { //$monopetImage1 = mysql_result($result2,$i,"monopetImage1"); $monopetName = mysql_result($result4,$i,"monopetName"); $monopetSpecies = mysql_result($result4,$i,"monopetSpecies"); $monopetDOB = mysql_result($result4,$i,"monopetDOB"); $monopetID = mysql_result($result4,$i, "monopetID"); $query = "SELECT `lastDateFed` as lastDatefed FROM `chibifriendspets` WHERE `monopetID` = '$monopetID'"; $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $lastDatefed = $query_data['lastDatefed']; $query = "SELECT `hunger` as hunger FROM `chibifriendspets` WHERE `monopetID` = '$monopetID'"; $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $hunger = $query_data['hunger']; $query = "SELECT `happy` as happy FROM `chibifriendspets` WHERE `monopetID` = '$monopetID'"; $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $happy = $query_data['happy']; $query = "SELECT `lastDateplay` as lastDateplay FROM `chibifriendspets` WHERE `monopetID` = '$monopetID'"; $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $lastDateplay = $query_data['lastDateplay']; //The pet gets hungrier $then = strtotime($lastDatefed); $right_now = time(); $timesincefed = $right_now - $then; $dayssincefed = number_format($timesincefed/86400,2); $days = round($dayssincefed); if ($days == 0) { $hunger2 = $hunger; } elseif ($days > 9) { $hunger2 = 9; } else { $hunger2 = $days; } $query = "UPDATE chibifriendspets SET hunger = '$hunger2' WHERE monopetID = '$monopetID'"; $result = mysql_query($query ,$connection); //The pet gets Sadder $then2 = strtotime($lastDateplay); $right_now2 = time(); $timesinceplay = $right_now2 - $then2; $dayssinceplay = number_format($timesinceplay/86400,2); $days2 = round($dayssinceplay); if ($days2 == 0) { $happy2 = $happy; } elseif ($days2 > 9) { $happy2 = 9; } else { $happy2 = $days2; } $query = "UPDATE chibifriendspets SET happy = '$happy2' WHERE monopetID = '$monopetID'"; $result = mysql_query($query ,$connection); $i++; } } ?> </body> </html> I can't figure out what's wrong, could someone help? Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 15, 2007 Share Posted April 15, 2007 <?php session_start();// session_start should always be first include ("config2.php"); if ((!$_POST['preuserName']) || (!$_POST['preuserPassword'])) { header("Location:http://www.$domain/demo/login.php"); exit; } else { $db = mysql_select_db($db_name, $connection) or die("Couldn't select database2."); $sql = "SELECT * FROM chibifriends WHERE preuserName ='$preuserName' AND preuserPassword = '$preuserPassword' "; $result = mysql_query($sql,$connection) or die("Couldn't execute query."); $query_data = mysql_fetch_array($result); $preuserID = $query_data['preuserID']; $preuserAge = $query_data['preuserAge']; $cimage = $query_data['image']; $userstatus = $query_data['userstatus']; $num = mysql_num_rows($result); if ($num != 0) { // new way to register varaible $_SESSION['preuserName'] = $preuserName; $_SESSION['preuserID'] = $preuserID; $_SESSION['cimage'] = $cimage; $_SESSION['valid_user'] = $preuserAge; $_SESSION['userstatus'] = $userstatus; $session=session_id(); setcookie("NetPetzpreuserID", "$preuserID", time()+60*60*24*100, "/"); setcookie("NetPetzpreuserName", "$preuserName", time()+60*60*24*100, "/"); $domain = GetHostByName($REMOTE_ADDR); header("Location: ../home.php"); exit; } } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted April 15, 2007 Share Posted April 15, 2007 As your variables appear from nowhere I'm guessing register_globals has now been set OFF on your server http://www.php.net/manual/en/security.globals.php 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.