Jump to content

Marfisa

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Marfisa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Unfortunately, that won't work, since the error page is linked from several similar games. I'd need a separate error message for each game. I need some generic way of going back.
  2. I've got a little game running using PHP. It has a form to put in the correct answer. If you enter a wrong answer, it takes you to an error page and in Firefox you can either use the back button on your browser or the link to go back provided on the error page. But IE (at least IE6), trying either just gets you back to the error page and not the form to try again. Is there anyway to get IE to get back to the main form page from a link like this javascript: history.go(-1)? Here is my stripped down code- <?php if(!isset($_POST['submit'])) { ?> <form action="warped.php" method="post"> <input type="text" name="field1" size="20"> <input type="submit" value="Guess!" name="submit"> </form> <?php } else{ if ($_POST['field1']==$warped_answer) { ?> Stuff for correct answer goes here... <? } else { include('_error.php'); } } And _error.php contains this- <h1>try again!</h1> <p> Oops, that's not the right answer! Go <a href="javascript: history.go(-1)">back to the game</a> and try again.<br> (If you're using IE, go <a href="index.php">back to the game list</a>. The link above won't work for you.) </p>
  3. Oops, it must have been the heat earlier. $_SERVER['QUERY_STRING'] is the variable I was looking for! Never mind, topic solved.
  4. Hi, I'm trying to generate both a menu and page contents from a database, but can't figure out how to generate the page content. Maybe I'm just going about it the wrong way completely. Here are the relevant parts of the code. (Hence all the jumping in and out of php.) <?php if(!$_SERVER['QUERY_STRING']) { ?> <? $i=0; while ($i < $num) { $deck_name=mysql_result($result,$i,"deck_name"); $deck_type=mysql_result($result,$i,"deck_type"); $deck_cat=mysql_result($result,$i,"deck_cat"); $deck_desc=mysql_result($result,$i,"deck_desc"); $id=mysql_result($result,$i,"id"); if ($deck_cat=="moon") { ?> <tr> <td class="sub"><? echo "$deck_desc"; ?></td> <td class="subc"><a class="table" href="index.php?<? echo "$deck_name"; ?>"><? echo "$deck_name"; ?></a></td> <td class="subc"><? if ($deck_type=="0") {echo "20";} else {echo "10";} ?></td> </tr> <? } ++$i; } ?> <? } if($_SERVER['QUERY_STRING'] == "deck_name_here") { ?> <h1>Content here based on deck_name_here</h1> etc. page content here. The part I can't figure out is $_SERVER['QUERY_STRING'] == "deck_name_here" where "deck_name_here" should be a variable. It's the $deck_name in the menu that's generated by the database. Or are there better ways to handle this? Thanks in advance for any help. I'd really appreciate it.
  5. Hi GingerRobot, Thanks for your help. I still got an error, but then I realized that the problem all along was here! <form action="games_snoop.php?answer" method="post"> <input type="text" name="character" size="20"><br> <input type="submit" value="Guess!"> </form> The OLD file was named "games_snoop.php" to help me sort all the files that were lumped in my root directory for the subdomain. The new file was simply "snoop.php" and I overlooked the place in the form where it needed to be corrected. *headdesk* But your POST solution is much nicer than what we were using before, so I'll be fixing up the rest of the files to take advantage of that. Thanks again!
  6. The complete page is here: http://legend.neo-romance.net/games/snoop.txt
  7. Sorry if this there is an obvious answer, but I'm having trouble with this. I have some includes with full paths at the top of my page. Then I have this form- <form action="games_snoop.php?answer" method="post"> <input type="text" name="character" size="20"><br> <input type="submit" value="Guess!"> </form> Later in the page, I am using this bit of code to display if the answer was correct- <? } elseif ($_SERVER['QUERY_STRING'] == "answer") { The problem is that when it gets to the URL with games_snoop.php?answer, all the includes can no longer be found. I get this error. Warning: main(top.php) [function.main]: failed to open stream: No such file or directory in It looks like it's just looking for the included files in the current directory, ignoring the full path I had specified. This is the page with the problem if you want to see it in action. The correct answer for the form is "osakanaru". http://legend.neo-romance.net/games/snoop.php The includes work on the main part of the page.
  8. I managed to fix the problem with session ID showing up in the URL by adding this line to the top of the code, above the session start. [code] ini_set('url_rewriter.tags', ''); [/code] But I'm still getting errors with both Firefox and IE. Firefox sometimes comes up with a blank page when you first click a link and IE is still randomly shows blank pages as you click on the links.
  9. I made a silly little game using sessions and it's supposed to be using cookies, but in both Firefox (1.0.4) and IE (6.0.26), no matter which is the first link you click on (of the pets to trade with, not the sidebar), it will show the session id in the url when I thought it was supposed to be using cookies. You have to go back one page to get it to work again. Also, in IE, it randomly (to me anyway) shows blank pages when you click on the names. I'm sorry if this has already been answered somewhere, but I've had a really hard time trying to look up this problem since I don't know what it might be called. Oh, my domain is set for PHP4, and I don't have access to the server. Although I do have the option of switching it to PHP5. It's on PHP4 because changing it to 5 broke some other code on the site, although that's an issue for another post sometime. The first three lines of code above the session start are various fixes I've been trying, I don't know if they're necessary at all. To see this problem in action, here is the link- http://academy.neo-romance.net/games_trade2.php Here is the code, it's just a snippet, but all along the same vein. Also, I haven't quite finished coding the whole thing yet, so I haven't closed the session anywhere. I figured it was ok for it to end with the browser closing for my testing purposes. [code]     <?php     header('P3P: CP="CAO PSA OUR"');     header("Cache-control: private");     ini_set(session.use_only_cookies,1);     session_start();     include('top.php');     include('reward.php');     if (!$_SERVER['QUERY_STRING'])  {     if (!session_is_registered("active"))       {       session_register("active");       $active=1;       session_register("candy");       $candy="shrimp";       }     ?>     <h2>trick or trade!</h2>     <?     echo "<p>You have a " . $_SESSION['candy'] . "!</p>\n";     ?>     <P>     Who would you like to try trading with next?     </P>     <P align="center">     <a href="games_trade2.php?fatty">Mr. Fattykins</a> |     <a href="games_trade2.php?chunky">Chunkypuff</a> |     <a href="games_trade2.php?mishe">Mishe Mishe</a> |     <a href="games_trade2.php?itty">Ittypuff</a> |     <a href="games_trade2.php?bitty">Bittypuff</a> |     <a href="games_trade2.php?sydney">Sydney</a> |     <a href="games_trade2.php?trouble">Trouble</a>     </P>     <?     } elseif ($_SERVER['QUERY_STRING'] == "fatty") {     ?>     <h2>trick or trade!</h2>     <?     echo "<p>You have a " . $_SESSION['candy'] . "!</p>\n";     if ($_SESSION['candy']=="shrimp")       {       echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a tuna.</p>\n";       $_SESSION['candy']="tuna";       }     elseif ($_SESSION['candy']=="chicken leg")       {       echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a coral.</p>\n";       $_SESSION['candy']="coral";       }     elseif ($_SESSION['candy']=="scallop")       {       echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a snail.</p>\n";       $_SESSION['candy']="snail";       }     elseif ($_SESSION['candy']=="shell")       {       echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a prize.</p>\n";       $_SESSION['candy']="prize";       }     else       {       echo "<p>Mr. Fattykins is not interested in your "  . $_SESSION['candy'] . ".</p>\n";       }     ?>     <P>     Who would you like to try trading with next?     </P>     <P align="center">     <a href="games_trade2.php?fatty">Mr. Fattykins</a> |     <a href="games_trade2.php?chunky">Chunkypuff</a> |     <a href="games_trade2.php?mishe">Mishe Mishe</a> |     <a href="games_trade2.php?itty">Ittypuff</a> |     <a href="games_trade2.php?bitty">Bittypuff</a> |     <a href="games_trade2.php?sydney">Sydney</a> |     <a href="games_trade2.php?trouble">Trouble</a>     </P>     <?     }     include('bottom.php');     ?> [/code]
×
×
  • 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.