Warraven Posted April 15, 2009 Author Share Posted April 15, 2009 Okay it came up with this. (members_area.php) [\code] The Current Session ID is: Sorry there are no results for this person Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-810574 Share on other sites More sharing options...
jesushax Posted April 15, 2009 Share Posted April 15, 2009 right this means we dont have a session ID, the memebers area page is fine for now we need to go back to the checklogin see whats happening there replace this your checklogin with this one <?php include($_SERVER['DOCUMENT_ROOT'] . '/connection.php'); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT id FROM members WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql) or die(mysql_error()); //below we check for results then if we have results set sessions, if not write the error if (mysql_num_rows($result) > 0) { $user = mysql_fetch_array($result); $_SESSION["ID"] = $user["id"];//here we get the users ID echo "<p>SQL IS:".$sql."</p>"; echo "<p>USER ID IS:".$user["id"]."</p>"; //header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> then post the SQL IS: and the USER ID IS: results CHeers Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-810611 Share on other sites More sharing options...
Warraven Posted April 15, 2009 Author Share Posted April 15, 2009 Yep, it came up with this; SQL IS:SELECT id FROM members WHERE username='Admin' and password='costin123' USER ID IS:1 Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811070 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Share Posted April 16, 2009 sorry for long reply hope your still around so i can help... that page is fine then just delete the two echo statments and remove the two // from the header redirect just notice on the members_page.php my fault change it to this <?php session_start(); $ID = $_SESSION["ID"]; $selected = mysql_query("SELECT * FROM members WHERE id='$ID'") or die(mysql_error()); if (mysql_num_rows($selected) > 0) { while ($user = mysql_fetch_array($selected)) { echo "Username: ".$user["username"]."<br />"; echo "Email: ".$user["email"]."<br />"; echo "Level: ".$user["level"]."<br />"; echo "Health: ".$user["health"]."<br />"; echo "Strength: ".$user["strength"]."<br />"; echo "Agility: ".$user["agility"]."<br />"; echo "Intellect: ".$user["intellect"]."<br />"; echo "Main Hand: ".$user["main_hand"]."<br />"; echo "Off Hand: ".$user["off_hand"]."<br />"; echo "Class: ".$user["class_armor"]."<br />"; } }else { echo "<p>Sorry there are no results for this person</p>"; } ?> then let me know if it works? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811274 Share on other sites More sharing options...
Warraven Posted April 16, 2009 Author Share Posted April 16, 2009 No prob, lol. It came up with this; Sorry there are no results for this person Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811318 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Share Posted April 16, 2009 ok put session_start(); at the top of the checklogin.php and then lets try it all again hopefully have this sorted Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811328 Share on other sites More sharing options...
Warraven Posted April 16, 2009 Author Share Posted April 16, 2009 *Drum roll* Yay! It worked, the stats and stuff shows! Username: Admin Email: [email protected] Level: 1 Health: 30 Strength: 3 Agility: 3 Intellect: 3 Main Hand: Fist Off Hand: Fist Class: Traveler Thanks so much man, you've been very helpful. Is there anyway I can pay you back like a +rep or something? Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811332 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Share Posted April 16, 2009 glad we go there in the end, no dont think they have rep system here, its no trouble though glad i could help really Alex Quote Link to comment https://forums.phpfreaks.com/topic/154171-solved-help-with-a-mysqlphp-problem/page/2/#findComment-811335 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.