Jump to content
dmacfang8

why is it not showing right

Recommended Posts


<html>

 

<head>

 

<title>Take the Coolness Quiz!</title>

 

</head>

 

<body>

 

<h1>Find Out How Cool You Are</h1>

 

<form action="results.php" method="post">

 

 

 

<b>Question 1: Do you pick your nose?</b><br>

 

<input type="radio" name="q1" value="yes"> Yes <br>

 

<input type="radio" name="q1" value="no"> No <br>

 

 

 

<b>Question 2: Do you have any friends?</b><br>

 

<input type="radio" name="q2" value="yes"> Yes <br>

 

<input type="radio" name="q2" value="no"> No <br>

 

 

 

<b>Question 3: Is your hair styled in a fashionable way?</b><br>

 

<input type="radio" name="q3" value="yes"> Yes <br>

 

<input type="radio" name="q3" value="no"> No <br>

 

 

 

<b>Question 4: Can you dunk a basketball?</b><br>

 

<input type="radio" name="q4" value="yes"> Yes <br>

 

<input type="radio" name="q4" value="no"> No <br>

 

 

 

<b>Question 5: Do you get out much?</b><br>

 

<input type="radio" name="q5" value="yes"> Yes <br>

 

<input type="radio" name="q5" value="no"> No <br>

 

 

 

<br>

 

<input type="submit" value="Determine Your Coolness">

 

</form>

 

</body>

 

</html>


<?php

 

$score = 0;

 

if ($_POST['q1'] == 'no')

 

$score++;

 

if ($_POST['q2'] == 'yes')

 

$score++;

 

if ($_POST['q3'] == 'yes')

 

$score++;

 

if ($_POST['q4'] == 'yes')

 

$score++;

 

if ($_POST['q5'] == 'yes')

 

$score++;

 

?>

 

<html>

 

<head>

 

<title>Your Results for the Coolness Quiz!</title>

 

</head>

 

<body>

 

<h1>Your Results for the Coolness Quiz!</h1>

 

 

 

<?php

 

echo '<b>Your coolness score was ' . $score . '/5</b><br><br>';

 

if ($score < 3)

 

echo 'You are not very cool!';

 

else if ($score == 5)

 

echo 'Congratulations, a perfect score!';

 

else

 

echo 'Not bad, you scored average';

 

?>

 

 

 

</body>

 

</html>

Share this post


Link to post
Share on other sites

You have not described the problem. What is "right"?

Share this post


Link to post
Share on other sites

You have to install a server on your local computer in order to run PHP code.

Share this post


Link to post
Share on other sites

So that people can't view the source code and cheat.

Share this post


Link to post
Share on other sites

What are you talking about?

Share this post


Link to post
Share on other sites

Did you place your files in htdocs folder?

Did you use url starting with localhost? Example: localhost/htmlfile.html or localhost/phpfile.php

Share this post


Link to post
Share on other sites

Someone Try This Out And Tell Me What They See


<!DOCTYPE html>

<html>

    <head>

         <link rel="stylesheet" type="text/css" href="youtubersQuiz.css">

    </head>



<meta name="viewport" content="width=device-width, initial-scale=1">



<body>



<div id="mySidenav" class="sidenav">

  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">☓</a>

 <ul>

    <li>

        <a  href="home.html">Home</a>

        <a href="quiz.html">Quizzes</a>

        <a href="socialMedia.html">Social Media</a>

    </li>

</ul>

</div>



<div id="main">

<span style="font-size:30px;cursor:pointer" onclick="openNav()" button class="button">☰</button></span>

  <h2>Home</h2>

<a href = "https://www.paypal.me/dmacfang8" target="_blank"> Donate Please </a>  

</div>



<script>

function openNav() {

    document.getElementById("mySidenav").style.width = "250px";

    document.getElementById("main").style.marginLeft = "250px";

    document.body.style.backgroundColor = "rgba(0,0,0,0.4)";

}



function closeNav() {

    document.getElementById("mySidenav").style.width = "0";

    document.getElementById("main").style.marginLeft= "0";

    document.body.style.backgroundColor = "white";

}

</script>

     

</body>

</html>
<!DOCTYPE html>

<html>

    <head>

         <link rel="stylesheet" type="text/css" href="youtubersQuiz.css">

    </head>



<meta name="viewport" content="width=device-width, initial-scale=1">



<body>



<div id="mySidenav" class="sidenav">

  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">☓</a>

 <ul>

    <li>

        <a  href="home.html">Home</a>

        <a href="quiz.html">Quizzes</a>

        <a href="socialMedia.html">Social Media</a>

    </li>

</ul>

</div>



<div id="main">

<span style="font-size:30px;cursor:pointer" onclick="openNav()" button class="button">☰</button></span>

  <h2>Quizzes</h2>

</div>

<div id="auto">

<a href="dashie.html"> <img src="https://yt3.ggpht.com/-dXM7eqHZ7Vo/V0edHUTJMgI/AAAAAAAAAEg/v-Vx_s6xJCM04yQAICdl-nu9Dw76HK1hgCL8B/w2120-fcrop64=1,00005a57ffffa5a8-nd-c0xffffffff-rj-k-no/DGHEADER.jpg" >

<a href="sideman.html"> <img src="https://yt3.ggpht.com/-7fcmezdtJqo/VOzWUpPR48I/AAAAAAAAAFM/nepDL1MsEes/w1060-fcrop64=1,00005a57ffffa5a8-nd-c0xffffffff-rj-k-no/Banner-mm7games.png">

</div>

<script>

function openNav() {

    document.getElementById("mySidenav").style.width = "250px";

    document.getElementById("main").style.marginLeft = "250px";

    document.body.style.backgroundColor = "rgba(0,0,0,0.4)";

}



function closeNav() {

    document.getElementById("mySidenav").style.width = "0";

    document.getElementById("main").style.marginLeft= "0";

    document.body.style.backgroundColor = "white";

}

</script>

     

</body>

</html>
body {

    font-family: "Lato", sans-serif;

    transition: background-color .5s;

    

}



.sidenav {

    height: 100%;

    width: 0;

    position: fixed;

    z-index: 1;

    top: 0;

    left: 0;

    background-color: #111;

    overflow-x: hidden;

    transition: 0.5s;

    padding-top: 60px;

}



.sidenav a {

    padding: 8px 8px 8px 32px;

    text-decoration: none;

    font-size: 25px;

    color: #818181;

    display: block;

    transition: 0.3s

}



.sidenav a:hover, .offcanvas a:focus{

    color: #f1f1f1;

}



.closebtn {

    position: absolute;

    top: 0;

    right: 25px;

    font-size: 36px !important;

    margin-left: 50px;

}



#main {

    transition: margin-left .5s;

    padding: 16px;

}



@media screen and (max-height: 450px) {

  .sidenav {padding-top: 15px;}

  .sidenav a {font-size: 18px;}

}



.button {

  padding: 15px 25px;

  font-size: 24px;

  text-align: center;

  cursor: pointer;

  outline: none;

  color: #fff;

  background-color: #000;

  border: none;

  border-radius: 15px;

  box-shadow: 0 9px #999;

}



.button:hover {background-color: #000}



.button:active {

  background-color: #999;

  box-shadow: 0 5px #666;

  transform: translateY(4px);

}



#main {

    width: auto;

}



img {

    width: 100%;

    height: auto;

}
<html>

<head>

<title>Take the Coolness Quiz!</title>

</head>

<body>

<h1>Find Out How Cool You Are</h1>

<form action="results.php" method="post">



<b>Question 1: Do you pick your nose?</b><br>

<input type="radio" name="q1" value="yes"> Yes <br>

<input type="radio" name="q1" value="no"> No <br>



<b>Question 2: Do you have any friends?</b><br>

<input type="radio" name="q2" value="yes"> Yes <br>

<input type="radio" name="q2" value="no"> No <br>



<b>Question 3: Is your hair styled in a fashionable way?</b><br>

<input type="radio" name="q3" value="yes"> Yes <br>

<input type="radio" name="q3" value="no"> No <br>



<b>Question 4: Can you dunk a basketball?</b><br>

<input type="radio" name="q4" value="yes"> Yes <br>

<input type="radio" name="q4" value="no"> No <br>



<b>Question 5: Do you get out much?</b><br>

<input type="radio" name="q5" value="yes"> Yes <br>

<input type="radio" name="q5" value="no"> No <br>



<br>

<input type="submit" value="Determine Your Coolness">

</form>

</body>

</html>
<?php

$score = 0;

if ($_POST['q1'] == 'no')

$score++;

if ($_POST['q2'] == 'yes')

$score++;

if ($_POST['q3'] == 'yes')

$score++;

if ($_POST['q4'] == 'yes')

$score++;

if ($_POST['q5'] == 'yes')

$score++;

?>

<html>

<head>

<title>Your Results for the Coolness Quiz!</title>

</head>

<body>

<h1>Your Results for the Coolness Quiz!</h1>



<?php

echo '<b>Your coolness score was ' . $score . '/5</b><br><br>';

if ($score < 3)

echo 'You are not very cool!';

else if ($score == 5)

echo 'Congratulations, a perfect score!';

else

echo 'Not bad, you scored average';

?>



</body>

</html>

Share this post


Link to post
Share on other sites

If you are seeing PHP code in the browser then you are not using the web server. Double-clicking on a file does not work. You need to type the URL into the address bar. The domain name for a server installed on your local computer is "localhost", like dsonesuk showed. Type an HTTP URL into your browser if you want the server to execute the PHP. If the URL does not start with HTTP then you're not even using the web server.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...