sai Posted July 5, 2007 Share Posted July 5, 2007 Hi, I am trying to create a dice game in PHP and it requires the randomization of the dice. My problem is: if the player does not like his dice he can "refresh" the page or "go back" a page on the browser, to generate different dice. What code could I put in my PHP so that if the player clicks the "refresh" or "back button" on the browser, the browser would either stop it, or redirect to another page? Thanks. Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted July 5, 2007 Share Posted July 5, 2007 Would you not be better using javascript for this? An onclick and then a meta refresh? I know that would work. But i do not know alot about JS so i cant help any further. Quote Link to comment Share on other sites More sharing options...
sai Posted July 5, 2007 Author Share Posted July 5, 2007 Can you use onclick function for buttons in the browser? I can only find tutorials for it for forms. Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted July 5, 2007 Share Posted July 5, 2007 Yeah you can use it for hrefs or images as far as i know.. what im going to post is likely wrong cause i HATE Javascript with a vengence and dont know much about it but... <a href="#" onlclick="doJavaSomething()">Refresh The Dice</a> Im not sure about what you would put in the function but maybe a <meta refresh> tag. Is what i use alot of the time when using php header() location is out of the question. Andy Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 5, 2007 Share Posted July 5, 2007 Refresh: <a href="<?php echo $_SERVER['PHP_SELF']; ?>">Refresh</a> Back: <a href="javascript:history.back()">Back</a> Quote Link to comment 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.