Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how count submit buttons in php?
is clear???????
Posted
Comments
Mohibur Rashid 1-Jun-14 11:50am    
well, the trick is disable the submit button right away with javascript or to look it nicer keep a global variable that would say that the button is clicked

1 solution

XML
<?php
session_start();
?>
<html>
    <head></head>
    <body>
        <form method="post" action="submit.php">
            <input type="submit" name="count" value="Start counting" />
        </form>
        <?php
        if(isset($_POST['count'])){
            if(!($_SESSION['count'])){
                $_SESSION['count'] = 1;
            }else{
                $count = $_SESSION['count'] + 1;
                $_SESSION['count'] = $count;
            }
        }
        echo $_SESSION['count'];
        ?>
    </body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900