Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
HTML & PHP - Lucky 7 - a simple game
This article explains how to create a simple game of Lucky 7 with HTML and embedded PHP
In this example we will create a simplified version of a popular casino game called Lucky 7. You could easily extend it to conform the other gaming options of that device and even add "virtual money" to be consumed.
- A web browser
- PHP installed
We will only need to implement one HTML file, you could name it e.g. index.html, or whatever you wish. The required PHP code is embedded in the HTML page.
$game_message = "Example game of Lucky 7 - Hit ROLL!";
$slot1 = rand(1, 10);
$slot2 = rand(1, 10);
$slot3 = rand(1, 10);
if($slot1 == 7 || $slot2 == 7 || $slot3 == 7)
$game_message = "YOU WIN!";
$game_message = "YOU LOSE!";
$slot1 = "?";
$slot2 = "?";
$slot3 = "?";
<h2>Game of Lucky 7 - simple version</h2>
<form method="POST" Action=""><?PHP echo $_SERVER['PHP_SELF'];?">
<td width="15" align="center"><?PHP echo $slot1; ?></td>
<td width="15" align="center"><?PHP echo $slot2; ?></td>
<td width="15" align="center"><?PHP echo $slot3; ?></td>
<input type="submit" value="Roll" name="submit">
<?PHP echo $game_message; ?>
Google Chrome 19.0.1084.52 m
Feel free to add some "virtual money" betting and posible other winning options to create an interesting past-time for your webpage.