943,884 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 812
  • PHP RSS
Aug 2nd, 2008
0

Seeion handeling

Expand Post »
Hi all,
I try to make login page in PHP.But I unable to get the loginID/UserName in login_successful page.I try to do it by using session.Please anyone tell me how I solve this problem by using session.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shreyasi is offline Offline
8 posts
since Aug 2008
Aug 2nd, 2008
0

Re: Seeion handeling

hi shreya,
php Syntax (Toggle Plain Text)
  1. <?
  2. ob_start();
  3. include("../conn.php");
  4. if($_SERVER['REQUEST_METHOD']=="POST" && isset($_POST['rlog']))
  5. {
  6. $res="select * from `date_profiles` where email='".mysql_real_escape_string($_POST['login'])."' and password='".mysql_real_escape_string($_POST['pass1'])."'";
  7. $res1=mysql_query($res);
  8. $res2=mysql_num_rows($res1);
  9. if($res2==0)
  10. {
  11. echo "invalid user";
  12. } else{
  13. $res="select * from `date_profiles` where email='".$_POST['login']."' and password='".$_POST['pass1']."'";
  14. $res1=mysql_query($res);
  15. $row=mysql_fetch_assoc($res1);
  16. $id=$row['id'];
  17. session_unregister("user_id");
  18. session_register("user_id");
  19. $_SESSION['user_id']=$id;
  20. session_unregister("name");
  21. session_register("name");
  22. $_SESSION['name']=$row['fname'];
  23. header("location:index.php");
  24. }
  25. }
  26.  
  27. ?>
hope this will help u
Reputation Points: 21
Solved Threads: 29
Posting Whiz in Training
praveen_dusari is offline Offline
202 posts
since Jun 2008
Aug 2nd, 2008
0

Re: Seeion handeling

use this code in your application:
php Syntax (Toggle Plain Text)
  1. session_start();
  2. //these folllowing lines are after insert query...
  3. session_unregister('userid');
  4. session_unregister('password');
  5.  
  6. session_register('userid');
  7. session_register('password');
  8.  
  9. $_SESSION['userid']=$_POST['userid'];
  10. $_SESSION['uid']=$_POST['password'];

And in your next page:
php Syntax (Toggle Plain Text)
  1. session_start();
  2. echo $_SESSION['userid'];
  3. echo $_SESSION['password'];
let me know if any error comes....
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Aug 2nd, 2008
0

Re: Seeion handeling

hi,
the above code i posted in inlogin page and in outher page like login succesful u can use sessions like this
php Syntax (Toggle Plain Text)
  1. <table border="0" cellspacing="0" cellpadding="0">
  2. <? if(isset($_SESSION['user_id']) && isset($_SESSION['name'])) {?>
  3. <tr>
  4. <td width="113" class="us">Welcome :
  5. <?=$_SESSION['name'];?></td>
  6. <td width="19"><img src="../images/spacer.gif" width="12" height="1" /></td>
  7. <td width="10" bgcolor="#FF9999"><img src="../images/spacer.gif" width="1" height="1" /></td>
  8. <td width="12"><img src="../images/spacer.gif" width="12" height="1" /></td>
  9. <td width="96"><a href="signout.php" class="signup">LogOut</a></td>
  10. </tr>
  11. <? }else { ?>
  12. <tr>
  13. <td height="1" class="us">Welcome : <strong>Guest</strong></td>
  14. <td>&nbsp;</td>
  15. <td bgcolor="#FF9999"></td>
  16. <td>&nbsp;</td>
  17. <td><a href="#" class="signup">Sign Up </a></td>
  18. </tr>
  19. <? } ?>
  20. </table>
if user logged in then it will display welcome (username) otherwise it will display
welcome guest
i think its clear now any doubts let us know
Reputation Points: 21
Solved Threads: 29
Posting Whiz in Training
praveen_dusari is offline Offline
202 posts
since Jun 2008
Aug 2nd, 2008
0

Re: Seeion handeling

Thanks...It works in IE.But not in mizila...no error shown but after login not going to next page..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shreyasi is offline Offline
8 posts
since Aug 2008
Aug 2nd, 2008
0

Re: Seeion handeling

Could you please tell me,
what is the structure of data base for this program???
What is rlog here??($_POST['rlog'])
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shreyasi is offline Offline
8 posts
since Aug 2008
Aug 2nd, 2008
0

Re: Seeion handeling

I think $_POST['rlog'] is a submit button.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
roh3x2n is offline Offline
8 posts
since Oct 2006
Aug 4th, 2008
0

Re: Seeion handeling

hi shreyasi,
i wrote a script for login which has 2 fields username and password if user is already registered then he will simply login, these two fields are placed at right.php and included in every page and if he is not registered user he will register in registerpage,after completion he will be logged in. so, to avoid confusion fom which the user is logged in i took one hidden value rlog in one right.php,structure is pretty complex becoz i used same table for different modules in my project which may be very confusion for u(i think) based on ur requirement u create your
tables
Reputation Points: 21
Solved Threads: 29
Posting Whiz in Training
praveen_dusari is offline Offline
202 posts
since Jun 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: sending email
Next Thread in PHP Forum Timeline: Multiple type of users





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


Follow us on Twitter


© 2011 DaniWeb® LLC