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 $_S开发者_JS百科ESSION['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.
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;
?>
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
You're likely seeing that because you've got <?PHP
instead of <?php
.
精彩评论