View Full Version : displaying a username using a php login script

01-13-2007, 08:42 PM
Hi, can anyone help me?

I'm using a php login script and have a default page set that the user gets redirected to when he/she logs in.

What I want to to is make that page a little more personal by adding their login name at the top of the page. so if user 'John' logs in, the screen says 'welcome John' and the same for other users.

Its not database driven though, theres a php file in use for the usernames and passwords.

I'm fairly new to php scripting, so any help would be greatly appreciated.



01-13-2007, 08:48 PM
post your php login script

01-13-2007, 08:51 PM
which bit would you like? theres about 10 different files that make up the script! theres one for the actual username and pasword boxes:

<table width="800" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
<td width="884"><form id="form2" name="form2" method="post" action="">
<p><?php echo $slogin_text[$slogin_lang]["Username"]; ?>
<input type="text" name="slogin_POST_username" value="<?php echo $slogin_loginname; ?>" />
<br />
<?php echo $slogin_text[$slogin_lang]["Password"]; ?>
<input type="password" name="slogin_POST_password" />
<br />
<input type="submit" name="slogin_POST_send" value="<?php echo $slogin_text[$slogin_lang]["LoginButton"]; ?>" />

01-13-2007, 09:06 PM
need the bit that queries the database

01-13-2007, 09:15 PM
there is no database, it uses a php file or a text file to match the usernames and passwords.

Theres a file that sets variables, and specifies re-directions etc.

heres a link to the site that I got it from:


01-13-2007, 10:25 PM
I found this in the scripts user forum:
Hi. Yes, you can do it! Just add this to the webpage, in the place you want to display it:

<?php echo "Logged in as $slogin_Username"; ?>

So, for example, if you have a header file (like header.inc.php) you could add it there too. For example:

<title><?php echo $slogin_pagetitle;?></title>
<p><?php echo "Welcome $slogin_Username"; ?></p>

And then all pages would display the "Welcome xxxxx" message.


01-14-2007, 07:21 AM
thats absolutely brilliant! works a treat! many thanx for your help on this one

01-14-2007, 09:28 PM
Glad to help mcambridge!

If you want to look at a custom solution later, have a look at davidj's video tutorial on how to make a login script, which also includes code to output the username on the page:

01-15-2007, 01:52 PM
many thanx for the info! I might just do that if my site gets that big!

I now have another small issue which i cant seem to solve for love nor money!

would like to have 'Welcome Guest' displayed on the page, but when the user logs in, the word guest is replaced by their login name.

I've got it working perfectly for displaying the users name after login, but this would just add the finishing touch!

Any help would be much appreciated!

01-15-2007, 02:23 PM
<?php echo "Welcome Guest $slogin_Username"; ?>

01-15-2007, 04:51 PM
sorry i misread your post

here you go



echo "Welcome $slogin_Username";


echo "Welcome Guest";



01-15-2007, 05:42 PM
It doesnt seem to work, all it does is displays 'welcome guest' then the login name aswell. i.e. 'welcome guest mark'

I would like 'Welcome Guest' to be displayed when the user hasnt logged in, and then, if 'Mark' logs in, it would say 'Welcome Mark'

any help greatly appreciated!

01-15-2007, 05:43 PM
ah, no worries, didnt see ur reply! oops, appologies, will try now!

01-15-2007, 05:59 PM
yep, all works a treat, with a little tweaking, the only words that change are 'guest' and the 'username'.....

brilliant thanx for that....if you would like to have a look....www.spiral-focus.com

username = Mark
password = spiral

its just a tester one.

once again, many thanx for ur help!

01-15-2007, 06:12 PM
the logout failed for me!

redirect to a blank page