In this tutorial, we will do the game 4pics 1 word. This game can be seen and played in your mobile. But now, you can also do this in php with just simple coding.
Step 1:
Let's create the file named index.php(You can name this code anything you like it can be game.php etc.)
1.1 html(we will use some image here. 'Let's find some pics that will be anwered as Electricity') :)
<html>
<head>
<title>
PHP GAME
</title>
<style>
#center_answer{
text-align: center;
}
</style>
</head>
<body>
<h1>4 PICS 1 WORD: PHP VERSION</h1>
<div>
<img alt="falls" src="falls.jpg" width="250" height="250">
<img alt="windmill" src="windmill.jpg" width="250" height="250">
</br>
<img alt="lightning" src="lightning.jpg" width="250" height="250">
<img alt="solar_panel" src="panel.jpg" width="250" height="250">
</div>
<form action="verify.php" method="post">
<div><input type="text" name="answer" placeholder="Your Answer here..." id="center_answer" size="78"></div>
<div><input type="submit" name="enter" value="Enter"></div>
</form>
</body>
</html>
2.) We will now verify if the answer is correct. if yes, it will say correct! and if not it will say wrong answer pls. try again or else Invalid answer/Pls Put your answer.
verify.php
<?php
if(isset($_POST["enter"])){
if(($_POST["answer"])== null){
echo "Please input your Answer.";
}
elseif($_POST["answer"]== "electricity"){
echo "Correct!";
}
else{
echo "Wrong/Invalid answer.";
}
}
?>
3.) After this its up to you to create new set of pics :) Enjoy!
If you have some questions you can comment here and ill try to answer it :) thank you. Happy PHP coding.