using this php code, enter line(s) of code to redirect to another php page calle
ID: 3821674 • Letter: U
Question
using this php code, enter line(s) of code to redirect to another php page called point.php when button is clicked:
<html>
<head>
<title> Assignment 5</title>
<link rel="stylesheet" type="text/css" href="GameStyle.css">
<body>
<h1> <img src="casino+banner.jpg" width="1000" height="600" /> </h1>
<center>
<form action="main.php" method="post">
<p id="headerText"> Welcome to Online Craps </p>
<?php
$diceRoll1= rand (1 ,6);
$diceRoll2= rand (1 ,6);
session_start();
$_SESSION["dice1"] = $diceRoll1;
$_SESSION["dice2"] = $diceRoll2;
$_SESSION["point"] = $diceRoll1+$diceRoll2;
echo ""."<Center>";
if ($diceRoll1==1){
} elseif ($diceRoll1==2) {
} elseif ($diceRoll1==3) {
} elseif ($diceRoll1==4) {
}elseif ($diceRoll1==5) {
} elseif ($diceRoll1==6) {
}
if ($diceRoll2==1){
} elseif ($diceRoll2==2) {
} elseif ($diceRoll2==3) {
} elseif ($diceRoll2==4) {
}elseif ($diceRoll2==5) {
} elseif ($diceRoll2==6) {
}
echo "You rolled a ".$_SESSION["point"]."<br>";
if ( $_SESSION["point"] == 2 OR $_SESSION["point"] == 3 OR $_SESSION["point"] == 12) {
echo "Sorry, You Lose";
echo '<p><a href="main.php"><button>Play Again</button></a></p>';
}
else if($_SESSION["point"]==4 OR $_SESSION["point"] == 5 OR $_SESSION["point"] == 6 OR $_SESSION["point"] == 8 OR $_SESSION["point"] == 9 OR $_SESSION["point"] == 10){
echo "You're Going To The Point Round!";
edit/add a line so when this button is clicked it goes to the point.php page
echo '<p><a href="point.php"><button>Click to proceed to the Point Round!</button></a></p>';
}
else if($_SESSION["point"]==7 OR $_SESSION["point"] ==11){
echo '<img src="win.jpg" width="400" height="300" />'."<br>";
echo '<p><a href="main.php"><button>Click to play again!</button></a></p>';
}
?>
</head>
<body>
</body>
</html>
Explanation / Answer
Hi,
I have edited the code to go to point.php when the button is clicked.
Please find the edited code below:-
CODE:-
<html>
<head>
<title> Assignment 5</title>
<link rel="stylesheet" type="text/css" href="GameStyle.css">
<body>
<h1> <img src="casino+banner.jpg" width="1000" height="600" /> </h1>
<center>
<form action="main.php" method="post">
<p id="headerText"> Welcome to Online Craps </p>
<?php
$diceRoll1= rand (1 ,6);
$diceRoll2= rand (1 ,6);
session_start();
$_SESSION["dice1"] = $diceRoll1;
$_SESSION["dice2"] = $diceRoll2;
$_SESSION["point"] = $diceRoll1+$diceRoll2;
echo ""."<Center>";
if ($diceRoll1==1){
} elseif ($diceRoll1==2) {
} elseif ($diceRoll1==3) {
} elseif ($diceRoll1==4) {
}elseif ($diceRoll1==5) {
} elseif ($diceRoll1==6) {
}
if ($diceRoll2==1){
} elseif ($diceRoll2==2) {
} elseif ($diceRoll2==3) {
} elseif ($diceRoll2==4) {
}elseif ($diceRoll2==5) {
} elseif ($diceRoll2==6) {
}
echo "You rolled a ".$_SESSION["point"]."<br>";
if ( $_SESSION["point"] == 2 OR $_SESSION["point"] == 3 OR $_SESSION["point"] == 12) {
echo "Sorry, You Lose";
echo '<p><a href="main.php"><button>Play Again</button></a></p>';
}
else if($_SESSION["point"]==4 OR $_SESSION["point"] == 5 OR $_SESSION["point"] == 6 OR $_SESSION["point"] == 8 OR $_SESSION["point"] == 9 OR $_SESSION["point"] == 10){
echo "You're Going To The Point Round!";
<button name="Click to proceed to the Point Round!">
<script type="text/javascript">
function directopoint()
{
var url = "point.php";
window.location(url);
}
</script>
</button>
</a></p>';
}
else if($_SESSION["point"]==7 OR $_SESSION["point"] ==11){
echo '<img src="win.jpg" width="400" height="300" />'."<br>";
echo '<p><a href="main.php"><button>Click to play again!</button></a></p>';
}
?>
</head>
<body>
</body>
</html>
======================================================================================
Please let me know in case of clarification.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.