You are here: newbie session code problem « PHP Language « IT news, forums, messages
newbie session code problem

Posted by Xylene2301 on 09/29/84 12:00

Here are snips from 2 pages; tst1.php and tst2.php

tst1.php echos the session id, then sets and echos a session variable called
username.

pressing a button on tst1.php submits to a form tst2.php which echos the
session id (successfully) and attempt to echo the username session vaiable
(fails). Why not?

The code is running on a shared server at Dreamhost, a really big hosting
svc. It's running php 4.4.7, register_globals is on,session support is
enabled.

Thanks for any help.

Here are the pages:

tst1.php************************************

<?php
session_start(); // start the session
$_SESSION['username'] = "Goody";
echo $PHPSESSID ."<br>";
echo $_SESSION['username'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>tst1</title>
</head>

<body>

<form method="post" name="ThisForm" action="tst2.php">
<button onclick="submit()">t2</button>
</form>

</body>
</html>


tst2.php************************************

<?php
echo $PHPSESSID ."<br>";
echo $username;
echo $_SESSION['username'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>tst2</title>
</head>

<body>

<form method="post" name="ThisForm" action="tst1.php">
<button onclick="submit()">t1</button>
</form>

</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация