ICubis2 Posted April 12, 2011 Share Posted April 12, 2011 I have a problem that is particular to the FF and Safari browsers. I do not see the problem in IE. Again, I am very new to php programming - no formal training - just a hacker. I have a web page that presents a form with a results table and a SUBMIT button. Each time the button is selected I want to present one of two different tables of results. Everything works fine the first time I hit the SUBMIT button. The page updates and shows the second table. But on the next SUBMIT the script that swaps things around is executed twice in FF and Safari vs. one time like in EI. This results in the same result table being displayed over and over vs. the two switching back and forth. Any idea what could be going wrong in these two browsers? Here's my swap script: <?php session_start(); // This script reverses the coin flip to see what would happen the other way if ($_SESSION['Coin_Flip'] == "heads") { //switch to tails $_SESSION['Coin_Flip'] = "tails"; include ('tails_algo.php'); } elseif ($_SESSION['Coin_Flip'] == "tails") { $_SESSION['Coin_Flip'] = "heads"; include ('heads_algo.php'); } include ('kind-comp_result.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/ Share on other sites More sharing options...
sunfighter Posted April 12, 2011 Share Posted April 12, 2011 Any idea what could be going wrong in these two browsers? Probably nothing. I say -> program in FF and then see what IE has done with it. FF is far more compliant with the rules. Your included code does not show the problem. Maybe heads_algo.php or kind-comp_result.php does Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1200690 Share on other sites More sharing options...
Krash Posted April 12, 2011 Share Posted April 12, 2011 What do you get when you echo $_SESSION['Coin Flip'] at the top of the script? Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1200720 Share on other sites More sharing options...
ICubis2 Posted April 13, 2011 Author Share Posted April 13, 2011 The user selects a radio button in the beginning of the process to set the coin flip - either heads or tails. The initial results table show the result correctly. Also the first time the swap coin flip SUBMIT button is activated it works fine and shows the opposite. The problem is on the next activation of this same button. $_SESSION['Coin_Flip'] becomes the same thing (either heads or tails) because the script is being run through twice. Again, EI works correctly and only runs through the script once, so the user can toggle back and forth between the heads and tails results tables. FF and Safari start double executing the script on on each activation of the button from the 2nd time onward. Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1201080 Share on other sites More sharing options...
Krash Posted April 13, 2011 Share Posted April 13, 2011 This appears similar to the problem you had in your previous thread. It's browser dependent, so it's probably caused by the html form code, not the php script. Post the html. Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1201205 Share on other sites More sharing options...
ICubis2 Posted April 13, 2011 Author Share Posted April 13, 2011 Here's the section of HTML for the page the presents the results table: <div id="e16" style="position:absolute;left:177;top:147;width:418;height:573;"><script type="text/javascript"> function checkForm16() { return true; } </script> <?php echo "<form action='other_flip.php' method='post'>"; echo "<table border='1'>"; echo "<tr><th colspan='2'>Your competition results.</th></tr>"; echo "<tr> <th bgcolor ='#FFFF00'>Winning Team</th> <th>2nd Place Team</th></tr>"; echo "<tr> <th bgcolor ='#FFFF00'>".$_SESSION['win_num']."</th> <th>".$_SESSION['2nd_num']."</th></tr>"; $count =1; while ($count <= $_SESSION['rows']){ echo "<tr><td valign ='top'>"; echo "<tr><td bgcolor ='#FFFF00'>".$_SESSION['winner'][$count]."</td><td>".$_SESSION['second'][$count]."</td></tr>"; echo "</td><td valign ='top'>"; echo "</td></tr>"; $count++; } echo "<input type='submit' value='What if - opposite flip?'>"; echo "</table>"; echo "</form>"; //reset button echo "<form action='kind-comp_input.php' method='post'>"; echo "<input type='submit' value='Start Over'>"; echo "</form>"; ?> <!--$end exclude$--> </div> Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1201235 Share on other sites More sharing options...
ICubis2 Posted April 13, 2011 Author Share Posted April 13, 2011 S$%t - I apologize. This problem is being caused by the same HTML code that gave me the other problem. Somehow I reverted back to that other code without the fix. (All those lines of code commented out.) Making the fix again did take care of the problem. Again, sorry for wasting your time on this one. Quote Link to comment https://forums.phpfreaks.com/topic/233498-script-being-run-thru-twice-when-a-submit-button-is-selected/#findComment-1201242 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.