Jump to content

Archived

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

JackJack

*SOLVED* No Text

Recommended Posts

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>

Share this post


Link to post
Share on other sites
When a parameter if passed via URL (as yours is), the passed values are in the [b]GET[/b] array. Change:
[code]$action = $_POST[action];[/code]
to this:
[code]$action = $_GET['action'];[/code]

Share this post


Link to post
Share on other sites

×

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.