jpraj Posted March 19, 2010 Share Posted March 19, 2010 This is a small game i'm working to practice, but I'm founding a problem between "fround" and "sround" hope you can help me. <?php $playerid = 1;//test id require_once ("dbconnect.php"); $action = $_REQUEST["action"]; /** Functions **/ function rock($round){ echo "<form method=\"post\" action=\"rydar.php?action={$round}\">"; echo "<input type=\"text\" name=\"guess\" id=\"guess\"> "; echo "<input type=\"submit\" value=\"submit\">"; echo "</form>"; } function rockwin(){ $win = mysql_query("SELECT gamewon FROM isitar WHERE id = {$playerid} "); if ($win['gamewon'] == 0){ mysql_query("UPDATE isitar SET gamewon = 1 WHERE id = {$playerid} "); } if($win['gamewon'] == 1){ mysql_query("UPDATE isitar SET , gamewon = 2 WHERE id = {$playerid} "); echo "You have a really great eye! "; } if($win['gamewon'] == 2){ echo "You won 3 times, you are now the best"; } } /** End Functions **/ $rock = rand(1,3); mysql_query("UPDATE isitar SET gametry = 0, roundwin= 0 WHERE id = {$playerid}"); if ($action == ""){ echo "come and play, its a 2 out of 3 wins to get the prize, want to try it?"; rock("fround"); echo "{$rock}"; // for testing } } if ($action == "fround"){ $query = mysql_query("SELECT gametry FROM isitar WHERE id = {$playerid}"); $game = mysql_fetch_row($query); if($_POST["guess"] <= 0 || $_POST["guess"] > 4 ){ echo "That rock doesn't existes.. Don't fool with me. Let's try again"; rock("fround"); } elseif($_POST["guess"] == $rock){ echo "Congrats, you have found the rock, if you find it 1 more time you will win, 2 try, lets go, choose."; rock("sround"); mysql_query("UPDATE isitar SET gametry = 1,roundwin = 1 WHERE id = {$playerid}"); } elseif ($_POST["guess"] != $rock ){ echo "Sorry, you miss, it was on " . $_POST["guess"] . " you still got 2 more trys, lets go, choose."; rock("sround"); mysql_query("UPDATE isitar SET gametry = 1 WHERE id = {$playerid}"); } } /** Second round **/ if($action == "sround"){ $query = mysql_query("SELECT roundwin,gametry FROM isitar WHERE id = {$playerid}"); $game = mysql_fetch_row($query); if($game['1'] == 1){ if($_POST["guess"] <= 0 || $_POST["guess"] >= 4){ rock("sround"); } elseif ($_POST["guess"] == $rock ){ if($game['0'] == 1){ rockwin(); } elseif($game['0'] == 0){ echo "Congrats, you have found the rock, if you find it 1 more time you will win , 1 try left, lets go, choose."; rock("tround"); mysql_query("UPDATE isitar SET gametry = 2,roundwin = 1 WHERE id = {$playerid}"); } } elseif ($_POST["guess"] != $rock){ if($game['0'] == 1){ echo "Sorry, you miss, it was on " . $_POST["guess"] . " you still got 1 more try, lets go, choose."; rock("tround"); mysql_query("UPDATE isitar SET gametry = 2 WHERE id = {$playerid}"); } elseif($game['0'] == 0){ echo "Sorry, it seems you lost, it was on " . $_POST["guess"] . " it was the last chance you had to win 1 round, you lose, sorry."; mysql_query("UPDATE isitar SET gametry = 0, roundwin=0 roundwin WHERE id = {$playerid}"); } } } } /** Third Round **/ if ($action == "tround"){ $query = mysql_query("SELECT gametry FROM isitar WHERE id = {$playerid}"); $game = mysql_fetch_row($query); if($game['0'] == 2){ if($_POST["guess"] <= 0 || $_POST["guess"] >= 4){ echo "hi"; //rock("tround"); } if ($_POST["guess"] != $rock ){ echo "Ahh, sorry, it isn't you lucky day it seems.. Good luck next time"; } if ($_POST["guess"] == $rock ){ rockwin(); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/195869-theres-a-bug-between-the-2-_request-i-think/ Share on other sites More sharing options...
Mchl Posted March 19, 2010 Share Posted March 19, 2010 What kind of problem? ('does not work' is not a valid answer to this question) Quote Link to comment https://forums.phpfreaks.com/topic/195869-theres-a-bug-between-the-2-_request-i-think/#findComment-1028821 Share on other sites More sharing options...
jpraj Posted March 19, 2010 Author Share Posted March 19, 2010 When I click submit to go to action=fround to action=sround the page shows blank, instead of what I want. Quote Link to comment https://forums.phpfreaks.com/topic/195869-theres-a-bug-between-the-2-_request-i-think/#findComment-1028827 Share on other sites More sharing options...
Mchl Posted March 19, 2010 Share Posted March 19, 2010 Start here: http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide/page1 Also please use tags when pasting any code on forums. Quote Link to comment https://forums.phpfreaks.com/topic/195869-theres-a-bug-between-the-2-_request-i-think/#findComment-1028829 Share on other sites More sharing options...
oni-kun Posted March 19, 2010 Share Posted March 19, 2010 Why are you using a confusing array of $_REQUEST and $_POSTs? You should choose one or the other, $_REQUEST will find any value in POST/GET/COOKIE superglobals. Quote Link to comment https://forums.phpfreaks.com/topic/195869-theres-a-bug-between-the-2-_request-i-think/#findComment-1028836 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.