Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox value being filled with the php script

Status
Not open for further replies.

swathip

Programmer
Oct 10, 2009
17
US
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>

<input type="text" value="<?PHP if(isset($_SESSION['info']['lastname'])){echo $_SESSION['info']['lastname']; }?>" name="lastname"></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;?>


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


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


[red]how do i set this problem[/red]
thanks in advance.
 
Hi,

The problems you observe would indicate that the web server does not know how to parse the file correctly.

The most obvious place to start would be to check if your web server is configured to run php? ... and secondly with the file extension and path where the file exists.

Thanks,

Steven Parker
 
I agree with parkers. And also $_session needs to be in caps. PHP is case sensitive.

$_sessions is completely different to $_SESSIONS.

The array construct in PHP does not work like in Javascript. There is no "New" operator. You don't need to use it to initialize an array, but if you want to use it its used as follows:

$myarray=array();
or
$myarray=array('firtname'=>'somevalue', 'lastname'=>'someothervalue',...);






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top