提交PHP后禁用按钮

I have this code that when submitted, it generates random number from the array.

<?php 

    if(isset($_POST['roll'])) {
        $randarray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        $randselect = array_rand($randarray);
        $nr = $randarray[$randselect];
        echo '<p class="btn btn-info"> Branch: '. $nr. '</p>'; 
    }

?>

<form action="#" method="post">
    <button type="submit" class="btn btn-default" name="roll">Roll Branch </button> 
</form>

What I wanted to do is after the form was submitted, the button will be disabled. Any thoughts?

Just add disabled if the button is pressed, e.g.

<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST["roll"]) ? "disabled" : "";?>>Roll Branch </button> 

Add onclick="this.disabled='true';" for button tag

You can do this:

<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST['roll']) ? 'disabled="true"' : ''; ?> >Roll Branch </button>