Search
Left Quote    By failing to prepare, you are preparing to fail.
- Benjamin Franklin    
Right Quote
 
[login] | [Register]
Forum Index » General Discussion » Viewing Topic and Replies
Post Reply


        Viewing Topic: Complete Member System Problem
  This user is offline  Genius
  Subject: "Complete Member System Problem" Posted: @ 8:35 pm on Feb 18 2008   

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

Hey, I'm having a little problem. I searched these forums, but couldn't find the successful answer for me. I need to echo out the name of the user. Heres my code:
header.php

Code:
<?php
ob_start();
session_start( );
require_once($_ SERVER['DOCUMEN T_ROOT'].'/db_c onnect.php');
//check cookie
if ($_SESSION['log ged_in'] != 1 && isset($_COOKIE[ 'login_cookie'] )) {
list($user, $pass) = explode('[]', $_COOKIE['login _cookie']);
$qu = mysql_query(&qu ot;SELECT `user_password` FROM `members` WHERE `username` = '".addslas hes($user).&quo t;'";
if (mysql_num_rows ($qu) == 1) {
$passw = mysql_fetch_obj ect($qu);
if ($passw->use r_password == $pass) {
$_SESSION['logg ed_in'] = 1;
$_SESSION['user name'] = $user;
$_SESSION['pass word'] = $pass;
}
}
}
if(!isset($_SES SION['username' ]) && !isset($_SESSIO N['password'])) {
$_SESSION['logg ed_in'] = 0;
$user = "Guest&quo t;;
}
?>



My index:

Code:
<?php
session_start() ;
include('header .php');

echo ('<table border="0& quot; cellpadding=&qu ot;0" cellspacing=&qu ot;0" style="bor der-collapse: collapse" bordercolor=&qu ot;#111111" ; width="100 %" id="Head&q uot;>
<tr>
<td width="62% ">
<table border="0& quot; cellpadding=&qu ot;0" cellspacing=&qu ot;0" style="bor der-collapse: collapse" bordercolor=&qu ot;#111111" ; width="100 %" id="AutoNu mber7">
<tr>
<td width="58% ">
<a href="$sit eurl">
<img border="0& quot; src="image s/logo.png" ; width="506 " height="10 4">< /a></td&g t;
<td width="42% ">$_SES SION['username' ];</td>
</tr>
</table>' );
?>


By the Way, I even tried $user
Thanks in advance. Very Good tutorials though =D

Edited at 08:42:23 pm on 02/18/08


    Viewed: 5,824 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member System Problem" Posted: @ 11:12 pm on Feb 18 2008    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Try, <? echo($_SESSION[ 'username']); ?>




-bs0d | AllSyntax.com

    Viewed: 5,811 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: Complete Member System Problem" Posted: @ 3:03 am on Feb 19 2008    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

Thanks for fast reply, it fixed my problem, but instead of showing Guest or the username, it shows blank. I can see everything, but the username part. Is header.php causing this? Should I just copy n paste header variables?





Thanks in advance.




    Viewed: 5,803 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member System Problem" Posted: @ 4:14 am on Feb 19 2008    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Your header code should be on every page. Read back through the article if you need to. $_SESSION['use rname'] should be assigned "Guest&q uot; if a person is not logged in.




-bs0d | AllSyntax.com

    Viewed: 5,797 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: Complete Member System Problem" Posted: @ 8:24 pm on Feb 19 2008    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

Thanks for the reply. Everything works now after I copy the header code into top of index.php. I used $_SESSION['use rname'] but it didn't work so I tried $user once more and all works excellent.
Thanks!




    Viewed: 5,783 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank