Hide button if label value for X

Asked

Viewed 22 times

-1

I created a page that generates a verification code for the person when they click on the "Generate" button, so the page refreshes and the code is shown, how do I make the button on this page only appear when it has not generated the code? (When she has nothing from the database appears "Click on Generate Button", and when it is already checked in the row appears CHECKED) Follow below the page code

 <!DOCTYPE html>
 <html lang="en">
 <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <?php
    $pagina_name = User::userData('username'); ?>
    <body>

        <?php include 'templates/GalaxyServers/includes/header.php' ?>
        <?php include 'templates/GalaxyServers/includes/head-config.php' ?>
                       <?php
                        if (isset($_POST['salvarusuario']))
                        {
                            $usernamevariable =User::userData('username');

                            $upateUser = $dbh->prepare("UPDATE `users` SET `verifica_discord`= :discord WHERE `username`= :id");
                            $upateUser->bindParam(':discord', $_POST['discord']); 
                            $upateUser->bindParam(':id', $usernamevariable); 
                            $upateUser->execute(); 
                            echo'<div class="alert alert-info">Código Gerado!</div>';

                        }
                        ?>

        <div class="container">
            <div class="row">

 </div>

                <div class="col-lg-11">
                    <div class="panel panel-default" id="box-content">
                        <div class="panel-heading" id="box-title"><strong>Acesso Ao Discord Do Hotel </strong>
                        </i></small></div>
                        <p><strong>&nbsp;&nbsp;Click no botão abaixo para gerar um código para o discord! Depois de gerado, basta enviar no canal de verificações em nosso servidor!</strong></p>
                            <div class="panel-body">
                          <div class="form-group">
                                         <?php 
               if(User::userData('verifica_discord') != null) { $verifica_discord = User::userData('verifica_discord'); } else { $verifica_discord = 'Click No Botão Gerar';} ?>
                                        <label class="col-sm-2 col-sm-2 control-label">Código Discord</label>
                                        <div class="col-sm-10">
                                            <input type="text"  value="<?= $verifica_discord ?>" name="verifica_discord" class="form-control" readonly>
             <br>
             <form class="form-horizontal form-element col-12" action="" name = "salvarusuario" method="POST">
                          <button style="width: 140px;
                                        float: right;
                                        margin-bottom: 14px;" type="submit" name="salvarusuario" class="btn btn-success">Gerar</button>
                                        </div>
                                    </div><Br><br>
                                                                        <div class="form-group">
                                        <div class="col-sm-10">
                                            <input type="hidden"  value="<?php echo rand(1, 99999999999); ?>" name="discord" class="form-control">
                                        </div>
                                    </div><Br><br>
                                                <?php
                                                include_once 'includes/footer.php';
                                                ?>```

1 answer

-2

First you would have to look for a way to link the person to the generated code. Probably a user. I recommend to select and link the current session (it can be in your User object). I could create a method User::getCode(). Ai to hide the button, you would use the same check you did to display the message "click the generate button", just put an if between the html element :)

  • There is no way for example: if in <input> you have the value CHECKED or some number the button does not appear? Or only the button appears when you have nothing (Click Here To Generate)?

  • Because people are already linked to the code (The Site has login and etc), so when it checks in Discord, the bot changes its code in the database by "VERIFIED", or as soon as it generates, is already inserted in the user’s code in a column

Browser other questions tagged

You are not signed in. Login or sign up in order to post.