livewirerules Posted July 23, 2008 Share Posted July 23, 2008 I have a html form with a Submit and Reset buttons, Each time the user clicks on it the click count will be incremented and stored in a database. I want to know how to disable the buttons/gray out the buttons in the html form when the user has reached a certain amount of clicks stored in the DB, so that the user cannot continue anymore. Any help will be appreciated Link to comment https://forums.phpfreaks.com/topic/116205-disable-buttons-in-form/ Share on other sites More sharing options...
craygo Posted July 23, 2008 Share Posted July 23, 2008 you would query the database first to get the number of clicks then just use a simple if statement. <?php $disabled = $r['tablefield'] > 1 ? "disabled=\"disabled\"" : ""; echo "<input type=\"submi\"t name=\"submit\" value=\"submit\" $disabled />\n"; ?> Ray Link to comment https://forums.phpfreaks.com/topic/116205-disable-buttons-in-form/#findComment-597556 Share on other sites More sharing options...
JonnyThunder Posted July 23, 2008 Share Posted July 23, 2008 Or this... echo "<input type=\"submit\" name=\"submit\" value=\"submit\"" . (($r['tablefield'] > 1) ? (" disabled=\"disabled\"") : ("")) . " />\n"; (the same thing on one line, with the typo fixed) Link to comment https://forums.phpfreaks.com/topic/116205-disable-buttons-in-form/#findComment-597585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.