views:

187

answers:

3

Okay the code is,

code in first.php

 <?PHP
session_start();
include("script.php");
?>
<form action="script.php" method=POST>
<input type="text" value="<?PHP if(isset($_SESSION['info']['firstname'])){echo $_SESSION['info']['firstname']; }?>" name="firstname">
</form>

i have saved the file in php and the "script.php" page has all the code related to intialising the sessions in php like so

code in script.php

<? $info=new array();
$info['firstname]=$_POST['firstname'];
$info['lastname]=$_POST['lastname'];
session_start();
$_session['info']=$info;
?>

now when i open "first.php" in IE, the textbox is being filled with

<?PHP if(isset($_SESSION['info']['firstname'])){echo $_SESSION['info']['firstname']; }?>"

why is it so.thanks in advance.

A: 

Are you sure you access the page via a webserver?

In other words do you access it by http://youserver/first.php and not simply open the first.php file in IE file file:///path/first.php

Alexandru Luchian
+1  A: 

Its look like you have a syntax error in script.php, it should be like this:

<?php
$info=new array();
$info['firstname']=$_POST['firstname'];
$info['lastname']=$_POST['lastname'];
session_start();
$_session['info'] = $info;
?>
Nazariy
And session call is $_SESSION, not $_session
Cesar
A: 

You're likely seeing that because you've got <?PHP instead of <?php.

mattbasta