Jump to content


Photo

*SOLVED* No Text


  • Please log in to reply
2 replies to this topic

#1 JackJack

JackJack
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 31 March 2006 - 04:10 PM

When I Upload It And Try It Out It Doesnt Work. When I click the image It Doesn't do Anything.

Plz Help

Thank You


<?php


$computer = rand(1,3);
{
if ($computer == 1) $choice = 'rock' ;
if ($computer == 2) $choice = 'paper' ;
if ($computer == 3) $choice = 'scissors' ;
}

$action = $_POST[action];


if ($action == 'rock' && $choice == 'rock') {

echo "No One Wins";
exit;
}
if ($action == 'rock' && $choice == 'paper') {

echo "You Lose";
exit;
}
if ($action == 'rock' && $choice == 'scissors') {

echo "You Win";
exit;
}
if ($action == 'paper' && $choice == 'rock') {

echo "You Win";
exit;
}
if ($action == 'paper' && $choice == 'scissors') {

echo "You Lose";
exit;
}
if ($action == 'paper' && $choice == 'paper') {

echo "No One Wins";
exit;
}
if ($action == 'scissors' && $choice == 'rock') {

echo "You Losed";
exit;
}
if ($action == 'scissors' && $choice == 'paper') {

echo "You Win";
exit;
}
if ($action == 'scissors' && $choice == 'scissors') {

echo "No One Wins";
exit;
}
?>
<html>
<a href='http://www.battlemachines.net/test/rps.php?action=rock'><img src='http://www.battlemachines.net/test/rock.bmp'></a>
<br>
<a href='http://www.battlemachines.net/test/rps.php?action=paper'><img src='http://www.battlemachines.net/test/paper.bmp'></a>
<br>
<a href='http://www.battlemachines.net/test/rps.php?action=scissors'><img src='http://www.battlemachines.net/test/scissors.bmp'></a>
</html>


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 31 March 2006 - 04:33 PM

When a parameter if passed via URL (as yours is), the passed values are in the GET array. Change:
$action = $_POST[action];
to this:
$action = $_GET['action'];

Legend has it that reading the manual never killed anyone.
My site

#3 JackJack

JackJack
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 31 March 2006 - 04:47 PM

Thank You




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users