drkbpwk609294 2018-07-21 20:33
浏览 5
已采纳

按下按钮时替换一列文本

Okay so how is this possible to make im not sure what and how to google, so the title is the best thing i could come up with, as a summry.

Here is what i mean.

I have a Disclamer on this Web Site.

Something like this

<form method="post" action="introduction.php">

    <table style="height: 100px;">
    <tbody>
        <tr>
            <td class="align-middle">Disclaimer text</td>
        </tr>
    </tbody>
    </table>

    <hr />

    <th scope="row"><input type="submit" class="btn btn-danger" name="submit" placeholder="Submit" value="Accept"></th>
</form>

<?PHP
    if (isset($_POST['submit'])){
        echo 'accept is pressed';
    }
?>

So basically..when accept is pressed i want the Disclamer text to dissapear and some other thext should take it's place.

I hope this makes some sense.

Thank you.

  • 写回答

1条回答 默认 最新

  • duanjing9739 2018-07-21 20:56
    关注

    You can do this using a single cookie like this

    <?php
    if ( isset($_POST['submit']) ) {
        setcookie("GDPR_accepted", 1, time()+(60*60*24*30), '/' );
    }
    
    <form method="post" action="introduction.php">
        <table style="height: 100px;">
        <tbody>
            <tr>
    <?php
    if ( !isset($_COOKIE["GDPR_accepted"]) ) :
    ?>      
                <td class="align-middle">Disclaimer text</td>
    <?php
    else:
    ?>
                <td class="align-middle">OTHER TEXT</td>
    <?php
    endif;
    ?>
            </tr>
        </tbody>
        </table>
    

    But I am not quite sure wht you are putting the other text into a form. But I will let you sort that out :)

    Also if cookies are disabled, you will have to change this to store this flag in your database

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答