Jump to content

[SOLVED] Help with a Mysql+PHP problem


Warraven

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

*Drum roll*

 

Yay!

It worked, the stats and stuff shows!

 

Username: Admin

Email: red-hot-lava@hotmail.com

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.