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!
if($fname && $pas)
{
include 'connect.php';
$query=mysql_query("SELECT * FROM user WHERE fname='$fname'");
$numrows=mysql_num_rows($query);
if($numrows!==0)
{
while($row=mysql_fetch_array($query))
{
$dbname=$row['fname'];
$dbpassword=$row['pas'];
}
if(trim($fname)==trim($dbname) && trim($pas)==trim($dbpassword))
{
$_SESSION['user']=$row;
header('Location: welcome.php');
}
on another page when is get the user id or name using <?php $_session['user']['fname'] ?> or something id etc it cant fetch the value to another page, any solution please;
<?php
include 'session.php';
?>
here the session is included in the page
here is session code
<?php
$lifetime=600;
session_start();
//echo "hello";exit;
//setcookie(session_name(),session_id(),time()+$lifetime);
if( !isset($_SESSION['user'])) {
header("location:index.php");
}
?>
that i want to display
<?php
echo $_SESSION['user']['fname'];
?>
it says that fname is undefined variable
<?php
session_start();
// after validate form, store username and pwd to session
$_SESSION['user']=$row['fname'];
$_SESSION['pwd']=$row['pass'];
// Now the values are stored into session and you can retrieve in anywhere
?>
// another page
<?php
session_start();
echo 'welcome'.$_SESSION['user'];
?>