Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="en-US">
- <head>
- <meta charset="UTF-8">
- <title>My Simple PHP Game</title>
- <style>
- .game{
- background-color:orange;
- text-align:center;
- font-family:Calibri;
- position: absolute;
- width:200px;
- top:0;
- bottom: 0;
- left: 0;
- right: 0;
- height:75px;
- margin: auto;
- }
- h1,h2{
- font-family:Calibri;
- text-align:center;
- }
- </style>
- </head>
- <body>
- <h1>Simple Game made with PHP</h1> <!-- Page Title -->
- <h2>Find serial killer from three man, if you can't you will die.</h2> <!--Desc. of the game-->
- <?php ##OPEN NEW TAG FOR PHP
- $killer = rand(1, 3); # Determine a number 1 between 3 (1,2,3)
- if($_POST){ #If user do post action, It will work.
- $blamedman = $_POST['sel']; #Get who player selected man as number
- if($killer == $blamedman){ #if determined number equals to selected man number it will work
- echo '<p style="background-color:green;text-align:center;font-size:25px;font-family:Calibri;">You win, reloading in 3 seconds</p>'; #YOU WIN MESSAGE
- header("refresh: 3;"); #refreshs the page
- }
- else{ #if not equals it, you will die
- echo '<p style="background-color:red;text-align:center;font-size:25px;font-family:Calibri;">You died, reloading in 3 seconds</p>'; #YOU LOSE MESSAGE
- header("refresh: 3;"); #refreshs the page
- }
- }
- ?> <!-- close php tag -->
- <div class="game"> <!-- created game class (css) for good look -->
- <!----><a>Hint: Killer's name is contains "<?php #We gave them hint. So we will use php there
- if($killer == 1){ #If killer is John hint will show killer name is contains J
- echo 'J';
- }
- else if($killer == 2){ #If killer is John hint will show killer name is contains A
- echo 'A';
- }
- else if($killer == 3){ #If killer is John hint will show killer name is contains E
- echo 'E';
- }
- ?> "</a> <!-- -->
- <form method="post"> <!--THIS IS IMPORTANT, IF YOU DONT DO THAT IT WILL NOT WORK IF($POST]} SECTION-->
- <select name="sel"> <!--name is important too. we used name at php codes-->
- <option value="1">John</option> <!--These man value is 1-->
- <option value="2">Daniel</option> <!-- 2-->
- <option value="3">James</option> <!--3 -->
- </select>
- <input type="submit" value="Blame"> <!--Submit button, need for this game-->
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement