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.

hi shreya,

if($_SERVER['REQUEST_METHOD']=="POST" && isset($_POST['rlog']))
$res="select * from `date_profiles` where email='".mysql_real_escape_string($_POST['login'])."' and password='".mysql_real_escape_string($_POST['pass1'])."'";
echo "invalid user";
} else{
$res="select * from `date_profiles` where email='".$_POST['login']."' and password='".$_POST['pass1']."'";


hope this will help u

use this code in your application:

//these folllowing lines are after insert query...

And in your next page:

echo $_SESSION['userid'];
echo $_SESSION['password'];

let me know if any error comes....

the above code i posted in inlogin page and in outher page like login succesful u can use sessions like this

<table  border="0" cellspacing="0" cellpadding="0">
          <? if(isset($_SESSION['user_id']) && isset($_SESSION['name'])) {?>
            <td width="113" class="us">Welcome :
            <td width="19"><img src="../images/spacer.gif" width="12" height="1" /></td>
            <td width="10" bgcolor="#FF9999"><img src="../images/spacer.gif" width="1" height="1" /></td>
            <td width="12"><img src="../images/spacer.gif" width="12" height="1" /></td>
            <td width="96"><a href="signout.php" class="signup">LogOut</a></td>
          <? }else { ?>
            <td height="1" class="us">Welcome : <strong>Guest</strong></td>
            <td bgcolor="#FF9999"></td>
            <td><a href="#" class="signup">Sign Up </a></td>
          <? } ?>

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

Thanks...It works in IE.But not in mizila...no error shown but after login not going to next page..

Could you please tell me,
what is the structure of data base for this program???
What is rlog here??($_POST)

I think $_POST is a submit button.

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