Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create 2 php pages. 1.php This page should recreate the game of “Rock

ID: 3938928 • Letter: I

Question

I need to create 2 php pages.

1.php
This page should recreate the game of “Rock Paper Scissors”. It should have three radio buttons on it: “Rock”, “Paper”, and “Scissors” and also a “Submit” button. When the user clicks submit, it should submit their choice to 2.php.

2.php
This file should randomly pick “Rock”, “Paper”, or “Scissors” as the CPUs selection. It should then display the results of the game. Example output would be “Player: Rock. CPU: Scissors. Result: Win”. If the user didn’t submit a choice, an error should be displayed.

Explanation / Answer

1.php

<?php
echo '<form action="2.php" method="post" />
<input type="radio" name="user_choice" value="Rock" title="Rock" /> <br /><br />
<input type="radio" name="user_choice" value="Paper" title="Paper" /> <br /><br />
<input type="radio" name="user_choice" value="Scissors" title="Scissors" /> <br /><br />
</form> ';
?>

2.php

<?php
IF($_POST['user_choice']){
$user_choice = $_POST['user_choice'];
$Choosefrom= array(Rock, Paper, Scissors);
$Choice= rand(0,2);
$Computer=$Choosefrom[$Choice];
IF($user_choice == $Computer){
echo 'Player: '.$user_choice.' CPU: '.$Computer.'. Result: Win';
}
ELSE {
echo 'Player: '.$user_choice.' CPU: '.$Computer.'. Result: Lose';
}

}
?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote