944,026 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1600
  • PHP RSS
Nov 5th, 2009
0

Customized user login

Expand Post »
what is the script to customise a login. for example if "abc" logs in to the website, how do i get it to display "Welcome abc", if "pqr" logs in "Welcome pqr" and so on...

please help!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
rukshilag is offline Offline
101 posts
since Oct 2009
Nov 5th, 2009
0
Re: Customized user login
Click to Expand / Collapse  Quote originally posted by rukshilag ...
what is the script to customise a login. for example if "abc" logs in to the website, how do i get it to display "Welcome abc", if "pqr" logs in "Welcome pqr" and so on...

please help!
once the user logs in, save his username in the session variable.
PHP Syntax (Toggle Plain Text)
  1. session_start();
  2. if(username/password check)
  3. {
  4. //some code
  5. $session['username'] = $_POST['txtfield_name_username'];
  6. }
and you can echo it like this -
PHP Syntax (Toggle Plain Text)
  1. if(isset($session['username']) && $session['username'] !='')
  2. {
  3. echo "Welcome ".$session['username'];
  4. }else echo "Welcome guet";
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 5th, 2009
0

let me show u my files

frameset2.php
<FRAMESET ROWS="15%,*">
<FRAME SRC="banner.html" name="banner">

<FRAMESET COLS="20%,*">
<FRAME SRC="leftmenu.html" NAME=sidebar>
<FRAME SRC="welcome.html" NAME=main>
</FRAMESET>
</FRAMESET><noframes></noframes>

login.html
<form action="validateUserLogin.php" method="post">
Username <input type="text" name="textBox1" /> <br>
Password <input type="password" name="txtPassword" /> <br>
<input type="submit" value="Ok" />
<input type="button" value="Cancel" />
</form>
<p> <a href=""> New User? </a></p>

banner.php
<p align="center"> <font style="outline-style:none" size="+4" color="#FFFFFF"> ABC & Company </font> </p>
<body bgcolor="#666666">

where do i add the php script for it to work the way i mentioned above? as in if pqr logs in then --> welcome pqr~!
Reputation Points: 10
Solved Threads: 0
Junior Poster
rukshilag is offline Offline
101 posts
since Oct 2009
Nov 5th, 2009
0
Re: Customized user login
put this -
PHP Syntax (Toggle Plain Text)
  1. session_start();
  2. if(username/password check)
  3. {
  4. //some code
  5. $session['username'] = $_POST['txtfield_name_username'];
  6. }
inside login.html
and this -
PHP Syntax (Toggle Plain Text)
  1. if(isset($session['username']) && $session['username'] !='')
  2. {
  3. echo "Welcome ".$session['username'];
  4. }else echo "Welcome guet";
inside welcome.html
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 5th, 2009
0
Re: Customized user login
i will have to save those 2 as php files then right?
Reputation Points: 10
Solved Threads: 0
Junior Poster
rukshilag is offline Offline
101 posts
since Oct 2009
Nov 5th, 2009
0
Re: Customized user login
Click to Expand / Collapse  Quote originally posted by rukshilag ...
i will have to save those 2 as php files then right?
form your code, it seems that you already have those files.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 5th, 2009
0
Re: Customized user login
it didnt work - i inserted the code in login.php and welcome.php the way u mentioned, but nothing works
Reputation Points: 10
Solved Threads: 0
Junior Poster
rukshilag is offline Offline
101 posts
since Oct 2009
Nov 5th, 2009
0
Re: Customized user login
You need some sort of username and password verification

You could use some sort of MySQL query like this:
php Syntax (Toggle Plain Text)
  1. SELECT user_id, username FROM login WHERE username = '$user_username' AND password = '$user_password
  2.  

And put that in a conditional to see if it checks, and then if it does, set the session cookies like network18 said.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
phouse512 is offline Offline
75 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: mySQL TABLES
Next Thread in PHP Forum Timeline: What shoul i so if my host doesn't support cron job





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC