Variable Value is not visible in the second script

Dear All,
I have these 2 scripts.
a) it opens the session for the particular log in user
if(!session_is_registered($acc_name)){
header(“location:myprofile.php”);
}

b) is the file that is being called by a)
In that myprofile.php the variable $acc_name is not visible.

<?php
$name1 = $_POST[’$acc_name’];
echo $name1;
?>

I’m getting the following error
Undefined index: $acc_name
Please assist.
Thanks & Regards,
Micky

A post action has to happen for that index to exist, in other words a form button has to be pressed that why this function exists: http://php.net/manual/en/function.isset.php

Thanks. I used isset() the session is successful.
if ( isset( $_SESSION[‘acc_user’] ) ){}

I have another challenge. I wanted to use the variable acc_user to query the transaction table to display the order details.
I tried using
$name=$_POST[‘acc_user’];

and still getting error
Undefined index: acc_name

How to get the Value of the Variable???

Please assist…

Dear All,

I got the answer :slight_smile:
The following syntax worked.

$name = $_SESSION[‘acc_name’];

If there is any other better way anybody knows do post.

Sponsor our Newsletter | Privacy Policy | Terms of Service