Jump to content

[SOLVED] php sessions


dahwan

Recommended Posts

i am testing out sessions but i cant make them work. I tried to create a tiiny biiny game where i am suposed to write my name, and the results tells me if i wrote my name or not :P

Game.php :
[code]
<?php
session_start()
?>
<link rel="stylesheet" type="text\css" href="styles\main.css">
<table class="TextTable">
<tr>
<th>
Try and write "Tomas" in this box =P
</th>
</tr>
<tr>&nbsp;</tr>
<tr>
<td>
<form method="post" action="gameCheck.php">
<input type="text" name="name"><input type="submit" value="check">
</form>
</td>
</tr>
</table>
<br>
<table>
<tr>
<td>
Results:<br>
<?php
if(isset($_session['wrong']))
{
echo "" . $_session['wrong'] . "";
unset($_session['wrong']);
}
?>
</td>
</tr>
</table>
[/code]

gameCheck.php :
[code]
<?php
SESSION_START();
$name = $_POST['name'];

if ( $name == tomas ) {
$_session['wrong'] = "well look at that, you DO know how to write ;)";
header("location: game.php");
}
else{
$_session['wrong'] = "thats not my name!";
header("location: game.php");
}
?>
[/code]

The game (not showing any results)
[url=http://www.dahwan.com/game.php]http://www.dahwan.com/game.php[/url]

If anyone could tell me why this does not work that would be really nice.
Thanks!

DahWan
Link to comment
https://forums.phpfreaks.com/topic/31729-solved-php-sessions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.