Jump to content

Recommended Posts

when i pass the session , the sesion variable is not display in new-course.php

 

here the code.....pls help i am using php 4.0

 

page index.php

 

<?

session_start();

mysql_connect("localhost","trainee","123") or die ("Unable to connect to the server");

mysql_select_db("gddatab");

if(isset($HTTP_POST_VARS['usernameh']))

{

$uname=$HTTP_POST_VARS['usernameh'];

$upass=$HTTP_POST_VARS['passwordh'];

$sql=("select * from user where s_username ='$uname' and s_password ='$upass'");

$result=mysql_query($sql);

$recordset=mysql_fetch_assoc($result);

$recordset_count=mysql_num_rows($result);

if($recordset_count==1)

{

$_SESSION['name'] = $recordset['s_name'];

echo $_SESSION['name'];

echo '<script>window.location.href=\'new-course.php\'</script>';

}

else

{

session_destroy();

$failed=true;

}

}

 

new-course.php

 

<? session_start(); ?>

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">

<html>

<head>

<title></title>

</head>

<body >

<? echo $_SESSION['name']; ?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/69845-session-name-not-display/
Share on other sites

Check at new-cource.php are you getting set data in session ?

 

 

 

<?
session_start();
mysql_connect("localhost","trainee","123") or die ("Unable to connect to the server");
mysql_select_db("gddatab");
if(isset($HTTP_POST_VARS['usernameh']))
{
$uname=$HTTP_POST_VARS['usernameh'];
$upass=$HTTP_POST_VARS['passwordh'];
$sql=("select * from user where s_username ='$uname' and s_password ='$upass'");
$result=mysql_query($sql);
$recordset=mysql_fetch_assoc($result);
$recordset_count=mysql_num_rows($result);
if($recordset_count==1)
{
$_SESSION['name'] = $recordset['s_name'];
                    header("location:new-cource.php");
exit;
}
else
{
session_destroy();
$failed=true;
}
}

 

 

 

<? session_start(); 
                      echo "<pre>";
                      print_r($_SESSION);
?>
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
<html>
<head>
<title></title>
</head>
<body >
<? echo $_SESSION['name']; ?>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.