Seeion handeling

Reply

Join Date: Aug 2008
Posts: 8
Reputation: Shreyasi is an unknown quantity at this point 
Solved Threads: 0
Shreyasi Shreyasi is offline Offline
Newbie Poster

Seeion handeling

 
0
  #1
Aug 2nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 171
Reputation: praveen_dusari is an unknown quantity at this point 
Solved Threads: 21
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

Re: Seeion handeling

 
0
  #2
Aug 2nd, 2008
hi shreya,
  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
Failure is success if we learn from it
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Seeion handeling

 
0
  #3
Aug 2nd, 2008
use this code in your application:
  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:
  1. session_start();
  2. echo $_SESSION['userid'];
  3. echo $_SESSION['password'];
let me know if any error comes....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 171
Reputation: praveen_dusari is an unknown quantity at this point 
Solved Threads: 21
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

Re: Seeion handeling

 
0
  #4
Aug 2nd, 2008
hi,
the above code i posted in inlogin page and in outher page like login succesful u can use sessions like this
  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
Failure is success if we learn from it
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: Shreyasi is an unknown quantity at this point 
Solved Threads: 0
Shreyasi Shreyasi is offline Offline
Newbie Poster

Re: Seeion handeling

 
0
  #5
Aug 2nd, 2008
Thanks...It works in IE.But not in mizila...no error shown but after login not going to next page..
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: Shreyasi is an unknown quantity at this point 
Solved Threads: 0
Shreyasi Shreyasi is offline Offline
Newbie Poster

Re: Seeion handeling

 
0
  #6
Aug 2nd, 2008
Could you please tell me,
what is the structure of data base for this program???
What is rlog here??($_POST['rlog'])
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 8
Reputation: roh3x2n is an unknown quantity at this point 
Solved Threads: 1
roh3x2n roh3x2n is offline Offline
Newbie Poster

Re: Seeion handeling

 
0
  #7
Aug 2nd, 2008
I think $_POST['rlog'] is a submit button.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 171
Reputation: praveen_dusari is an unknown quantity at this point 
Solved Threads: 21
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

Re: Seeion handeling

 
0
  #8
Aug 4th, 2008
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
Failure is success if we learn from it
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC