PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hai friend iam new in php.
iam making a php application and checking username and password against DB.i have a problem how can i redirect the session value(username) to aunthonticate page.
my coding are like
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
echo $myusername;
$_SESSION['myusername'] = $myusername;
echo $_SESSION['myusername'];
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
in login_success.php the username value.is not showing
Last edited by Benjamin on Tue Jun 30, 2009 12:11 am, edited 1 time in total.
Reason:Added [code=php] tags.
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
//session_register("myusername");
//session_register("mypassword"); never put passwords in session data
echo $myusername;
$_SESSION['myusername'] = $myusername;
echo $_SESSION['myusername'];
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush(); //this does nothing
?>
Ya its showing the session value. but i have many user and and each user having their login id and password .when the new user login the last user session value is changed with new session value.
how to solve it pl help me.
the sessions should be seperate from each other. If user A logs on from one place,their session will be seperate from User B from another place. When the users log out,their sessions are destroyed. From what i understand, it seems that the statement has something to do with session contamination or something,which(to the best of my knowledge) cannot occur in php
i agree with a94060 but in my form when user A is login then in welcome note User Name A is displaying but when user B login then in last session value User Name A is destroyed and User B name is showing in User A login Form Also.