Posted by samudasu on 02/27/06 06:13
First of all, welcome to PHP. Before starting on sessions, i suggest
doing some more reading on variables "Chapter 12", and especially 12.9
for this particular script in the online edition of the PHP manual.
http://www.php.net/manual/en/language.variables.php
I'm not sure if you're learing from an old tutorial or book but there
have been several changes in the way PHP works compared to previous
versions. Here is one example.
When you check the value of langua after clicking on "<a
href="?langua=2">set langua=2</a>", you'll have to check it by doing
$_GET['langua'] instead of $langua.
Keep it simple when starting out.
page1.php............
<html>
<body>
send a variable to page2<br />
<a href="page2.php?color=blue">send blue</a><br />
<a href="page2.php?color=red">send red</a><br />
</body>
</html>
page2.php.............
<?php
session_start();
// assign color from page 1 into session
$_SESSION['current_color'] = $_GET['color'];
?>
<html>
<body>
<?php
print $_SESSION['current_color'];
}
?>
</body>
</html>
[Back to original message]
|