My first PHP script! Woo! I think this is finally the right language I've been searching for, it looks so much like mIRC and I love it!
You can see the script "in action" @ http://dark-purple.comuv.com/slots.php (yes I know I should have made a button form, but I CBA).
Go easy on me. D=
<?php
$slotone = mt_rand(1,3);
$slottwo = mt_rand(1,3);
$slotthree = mt_rand(1,3);
echo "Your numbers are: $slotone $slottwo $slotthree";
echo "<br />";
echo "<br />";
if ($slotone == 1 && $slottwo == 1 && $slotthree == 1) {
echo "Congratulations! You have won!";
}
else if ($slotone == 2 && $slottwo == 2 && $slotthree == 2) {
echo "Congratulations! You have won!";
}
else if ($slotone == 3 && $slottwo == 3 && $slotthree == 3) {
echo "Congratulations! You have won!";
}
else { echo "You have lost - please try again!"; }
?>
Keep it up, PHP is one of the best languages to learn IMO. Would have been better to do it like this though:
<?php
$slotone = mt_rand(1,3);
$slottwo = mt_rand(1,3);
$slotthree = mt_rand(1,3);
echo "Your numbers are: $slotone $slottwo $slotthree<br \><br \>";
if ($slotone == $slottwo and $slottwo == $slotthree) {
echo "Congratulations! You have won!";
}
else { echo "You have lost - please try again!"; }
?>
mt_rand() is better than rand() and you really only need a single if-statement.