Jump to content

Recommended Posts

are you using SESSION variables to store login details... how are you having users log in??

 

if you are using SESSIONS you will need soemthing like

 

<?php
$username = $_SESSION['username']; //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT [userdetails] FROM [tablename] WHERE username = '$username'");
?>

the site is www.narutotalesofthesannin.com

 

login code

 

    <?php

// Connects to your Database

mysql_connect("localhost", "username", "password") or die(mysql_error());

mysql_select_db("members") or die(mysql_error());

 

//Checks if there is a login cookie

if(isset($_COOKIE['ID_my_site']))

 

//if there is, it logs you in and directes you to the members page

{

$username = $_COOKIE['ID_my_site'];

$pass = $_COOKIE['Key_my_site'];

$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());

while($info = mysql_fetch_array( $check ))

{

if ($pass != $info['password'])

{

}

else

{

header("Location: player.php");

 

}

}

}

 

//if the login form is submitted

if (isset($_POST['submit'])) { // if form has been submitted

 

// makes sure they filled it in

if(!$_POST['username'] | !$_POST['pass']) {

die('You did not fill in a required field.');

}

// checks it against the database

 

if (!get_magic_quotes_gpc()) {

$_POST['email'] = addslashes($_POST['email']);

}

$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

 

//Gives error if user dosen't exist

$check2 = mysql_num_rows($check);

if ($check2 == 0) {

die('That user does not exist in our database. <a href=http://narutotalesofthesannin.com/join.php>Click To Sign Up</a>');

}

while($info = mysql_fetch_array( $check ))

{

$_POST['pass'] = stripslashes($_POST['pass']);

$info['password'] = stripslashes($info['password']);

$_POST['pass'] = md5($_POST['pass']);

 

//gives error if the password is wrong

if ($_POST['pass'] != $info['password']) {

die('Incorrect password, please try again.');

}

else

{

 

// if login is ok then we add a cookie

$_POST['username'] = stripslashes($_POST['username']);

$hour = time() + 3600;

setcookie(ID_my_site, $_POST['username'], $hour);

setcookie(Key_my_site, $_POST['pass'], $hour);

 

//then redirect them to the members area

header("Location: player.php");

}

}

}

else

{

 

// if they are not logged in

?>

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">

<table border="0">

<tr><td colspan=2><h1>Login</h1></td></tr>

<tr><td>Username:</td><td>

<input type="text" name="username" maxlength="40">

</td></tr>

<tr><td>Password:</td><td>

<input type="password" name="pass" maxlength="50">

</td></tr>

<tr><td colspan="2" align="right">

<input type="submit" name="submit" value="Login">

</td></tr>

</table>

</form>

<?php

}

?>

 

this is what i need and the code im using to show the profile information

 

 

 

<?php

$username = $_SESSION['username']; //this is the session variable containing the username of the person logged in.

$sql = mysql_query("SELECT [username] FROM [users] WHERE username = '$username'");

?>

<br>

Level:?

<br>

Skill:?

<br>

Cash:?

<br>

Health:?

<br>

Chakra:?

<br>

Gender:?

<br>

Rank:?

<br>

Kills:?

<br>

Location:?

<br>

Village:?

<br>

Kekkei Genkai:?

please encase your code using the [ code ] tags, thats why they are there...

 

also i see that you are using cookies... so on your profile page, do some output echos and see what echoing '$username = $_COOKIE['ID_my_site'];' displays...

 

i have just skimmed the code so let me know what this code does

 

<?php

echo $_COOKIE['ID_my_site'];

?>

just change ur $username variable to the cookie variable...like below...

 

<?php
$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT [username] FROM [users] WHERE username = '$username'");
?>

just reference it to your users table, i assume in your members table you have fields such as

 

level

skill

cash

health

 

etc

 

 

<?php

$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT username,level,skill,cash,health FROM members WHERE username = '$username'");


while($row = mysql_fetch_array($sql)) {

                    echo $row['username']."<br/>";
                    echo $row['skill']."<br/>";
                    // Just keep going
        }
?>

there is no use saying "this didnt work"... what didnt work??

 

show us the table structure for your members table... we need to have a better understanding of how your database is setup and the tables that are inside it..

 

show us your database struucture and the fields in your members table....

those are the variables

 

 

username  varchar(30)  latin1_swedish_ci    Yes  NULL    Browse distinct values    Change    Drop    Primary    Unique    Index    Fulltext

password varchar(32) latin1_swedish_ci Yes NULL Browse distinct values Change Drop Primary Unique Index Fulltext

skill mediumint(255) Yes 1500 Browse distinct values Change Drop Primary Unique Index Fulltext

chakra mediumint(255) No 100 Browse distinct values Change Drop Primary Unique Index Fulltext

rank varchar(255) latin1_swedish_ci No wannabe ninja Browse distinct values Change Drop Primary Unique Index Fulltext

bloodline varchar(250) latin1_swedish_ci Yes unknown Browse distinct values Change Drop Primary Unique Index Fulltext

kills longtext latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

level mediumint(255) Yes 1

try this code

 

<?php

$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT * FROM members WHERE username = '$username'");


   while($row = mysql_fetch_array($sql)) {

                    echo $row['username']."<br/>";
                    echo $row['skill']."<br/>";
                    echo $row['chakra']."<br/>";
                    // Just keep going
        }
?>

turn on error_reporting and let me know if any errors are displayed...

 

delete everything in the profile page and add the code below, upload and let me know if any errors come up.

 

<?php
error_reporting(E_ALL); // TURN ON ERROR REPORTING TO DISPLAY ALL ERRORS

$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT * FROM members WHERE username = '$username'");


   while($row = mysql_fetch_array($sql)) {

                    echo $row['username']."<br/>";
                    echo $row['skill']."<br/>";
  
        }
?>

well i am looking at the page now and it is displaying fine for me

 

in your database, against the username 'tester' fill in all the other fields with numbers or text to see if they are displayed on the screen....

 

at this present moment, the page is showing correctly to me

 

 

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.