Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.