OK, I'm building a Web-based game. In order to utilize certain functions I always wanted to have, I need to use PHP. No big deal, just another language to learn. Now, I'm trying to set up variables that can be passed from page to page. I assume it works, but I'd never know: the darn echo won't work.
I have set up two pages for testing PHP: test1 and test2. I'm setting up a health system, and want to remove 25 health. OK, my code is:
test1.php
test2.php:
OK, I get no errors, but I can't get the variable to echo. If I put the variable in quotes, the ECHO works, but obviously it's not the variable I see. If I set up the code nice and pretty, I can't see any numbers. What am I doing wrong?
I have set up two pages for testing PHP: test1 and test2. I'm setting up a health system, and want to remove 25 health. OK, my code is:
test1.php
Code:
<?php
session_start("healthmeter");
$_SESSION["health"] = 100;
?>
<html>
<head>
<title>Test page for PHP</title>
</head>
<body>
<p><a href="test2.php">Take off 25% health</a></p>
<p><?php
echo $health;
?> </p>
</body>
</html>
test2.php:
Code:
<?php
session_start();
$_SESSION["health"] -= 25;
?>
<html>
<head>
<title>Test page for PHP</title>
</head>
<body>
<p><?php
echo $health;
?> </p>
</body>
</html>
OK, I get no errors, but I can't get the variable to echo. If I put the variable in quotes, the ECHO works, but obviously it's not the variable I see. If I set up the code nice and pretty, I can't see any numbers. What am I doing wrong?