Jump to content

Form Submit


Recreational_Champ

Recommended Posts

Hello all~  I have made a php game printing out images using a multidimensional array stored within a session variable named 'board.'  I am having quite some time trying to navigate the current state of my player. 

 

<form action="this.php" method="get" accept-charset="utf-8">
<input type="submit" name="right" value="→">
<input type="submit" name="left" value="←">
<input type="submit" name="up" value="↑">
<input type="submit" name="down" value="↓">
<input type="submit" name="reset" value="reset;">
</form>

 

 

if(isset($_GET['right']))
{
$dir = "right";
move($dir);
}
if(isset($_GET['left']))
{
$dir = "left";
move($dir);
}
if(isset($_GET['up']))
{
$dir = "up";
move($dir);
}
if(isset($_GET['down']))
{
$dir = "down";
echo "$dir";
}
if(isset($_GET['reset']))
{
session_destroy();
   setcookie(session_name(),"", time() - 3600);
   $_SESSION=array();
echo "reset";

 

 

Now, I can move the player in any direction I choose, but I have to hit the submit button "twice" to get the player to move only after I have moved in a different direction. 

 

Example:

 

New session started, player in a random position...

 

Try to navigate player up/down/left/right and it will move in the direction I last clicked "once" before moving the current selection... even when cookies/sessions have been cleared.

 

Somehow the submit GET status retains last moved state;  I am one click behind and cannot figure it out

 

 

My move() is working just fine!  Problem occurs when I submit reset as well.

 

 

A walk through would be very helpful :)

 

Thanks

Link to comment
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.