Jump to content

Rider_007

New Members
  • Posts

    4
  • Joined

  • Last visited

Rider_007's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ohh actually, we did this thing in the classroom, the teacher was there helping us, and when we finished he just told us to take this at home, to add 2 new forms and to do the stuff that i already asked before...i know my code it's confusing you,(it's confusing me too) but as i told you i know only few things about php, and if you open my mind right now you will find only confusing php codes coming around lol! i really don't know what to do, i tried some things earlier before you give me this answer but no way, i cant do it, and these dice pictures on the code are making my job even harder! i see you know of course something more than me, so cant you try do the code for me please i will never make it,even if im trying to see other examples on internet, this makes me more confused :/ Thank you!
  2. ohh, yes the best way for me as i can see is using these session variables...i totally understood how it works! but i still have problems, i know i'm doing something wrong here but i don't know exactly what, when the page opens it always displays the message:"Wrong Answer.The Correct Answer is:" and when i press the submit button it shows: Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost 4/19/2014 2:11:18 PM Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1..... Take a look on what i did please and help me :/ thanks! <?php require_once("funksione.php"); if (isset($_POST['ran,ran1,ran2,ran3'])) { echo "Correct Answer!"; } else { echo "Wrong Answer.The Correct Answer is:!"; } $ran = rand(1, 6); $_SESSION['answers']['ran'] = $ran; $ran1 = rand(1, 6); $_SESSION['answers']['ran'] = $ran1; $ran2 = rand(1, 6); $_SESSION['answers']['ran'] = $ran2; $ran3 = rand(1, 6); $_SESSION['answers']['ran'] = $ran3; echo "<br/>"; echo "In totally there are ". total_kings($ran,$ran1,$ran2,$ran3). " kings and ". total_soldiers($ran,$ran1,$ran2,$ran3). " soldiers."; echo "<br/>"; print "<img src=images/". $ran .".jpg>"; print "<img src=images/". $ran1 .".jpg>"; print "<img src=images/". $ran2 .".jpg>"; print "<img src=images/". $ran3 .".jpg>"; ?>
  3. ahh i'm so confused right now, i couldn't make it in the right way to get the result that i wanted, i'm not much advanced in php, i'm new.. that is the problem my friend, i need help on code that is used to compare the expected value with the value that the user provides, i saw some other examples on google, i tried to do something but couldnt connect it :S
  4. Hello there.!this is a little game with 6 dice pictures, when you reload the page it shows you how many 'kings' and 'soldiers' are in totally in the given random pictures! each time you reload the page the number of kings and soldiers change.. Now my problem is that i want to make it like, the user should write how many 'kings' and 'soldiers' are there and when he press the submit button, a message will show if his answer is correct or not..if its not, it should display the correct number of kings and soldiers that are there! (the 'kings' are the circles in the middle of each pic! if there's no circle in the middle of any pic, that means there are no 'kings' there) i spent lot of hours with this, trying to do it with if else if and with switch cases but the only thing i got, were errors -.- i hope some 1 of you will help me to solve this! HERE ARE 2 PICS OF HOW IT LOOKS LIKE: http://imgur.com/EVP8mMQ,HaMZL6q#0 http://imgur.com/EVP8mMQ,HaMZL6q#1 THIS IS THE CODE OF THE FIRST PAGE: <?php function count_soldiers($res) { switch($res){ case 1: return 0; break; case 2: return 2; break; case 3: return 2; break; case 4: return 4; break; case 5: return 4; break; case 6: return 6; break; } } function count_kings($res) { switch($res){ case 1: return 1; break; case 2: return 0; break; case 3: return 1; break; case 4: return 0; break; case 5: return 1; break; case 6: return 0; break; } } function total_kings($r1,$r2,$r3,$r4) { $totking = count_kings($r1)+count_kings($r2)+count_kings($r3)+count_kings($r4); return $totking; } function total_soldiers($r1,$r2,$r3,$r4) { $totsoldier = count_soldiers($r1)+count_soldiers($r2)+count_soldiers($r3)+count_soldiers($r4); return $totsoldier; } ?> AND THIS IS THE CODE OF THE SECOND PAGE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>How many kings are?</title> </head> <body bgcolor="#e0e0e0"> <div align="center"> <p><h2>How many kings and soldiers are in totally? </h2> </p> <hr/> <?php require_once("funksione.php"); $ran = rand(1, 6); $ran1 = rand(1, 6); $ran2 = rand(1, 6); $ran3 = rand(1, 6); echo "<br/>"; echo "In totally there are ". total_kings($ran,$ran1,$ran2,$ran3). " kings and ". total_soldiers($ran,$ran1,$ran2,$ran3). " soldiers."; echo "<br/>"; print "<img src=images/". $ran .".jpg>"; print "<img src=images/". $ran1 .".jpg>"; print "<img src=images/". $ran2 .".jpg>"; print "<img src=images/". $ran3 .".jpg>"; ?> <p><h2>How many kings and soldiers are in totally? </h2> </p> <form method="post" action="example11-2.php"> Kings: <input type="text" name="name" /> <form method="post" action="example11-2.php"> Soldiers: <input type="text" name="name" /> <input type="submit" /> </form> </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.