dsbm49845 2011-03-22 05:27
浏览 47
已采纳

如何为用户而不是管理员(PHP)创建文本框readonly / disable?

I'm trying this stuff but all I found is TinyMCE codes. Can you help me in here? I'm creating a system with tables(input type="text").. Where I can put my daily allowance for monday-friday's. I want that only me can put numbers on that textarea.. When other users logged in, the textarea is disabled/not editable.. How can I start with the coding? I start studying php yesterday :)

  • 写回答

4条回答 默认 最新

  • dou9022 2011-03-22 05:32
    关注

    Generally speaking, in this kind of case, you'll want to display input fields to your admin :

    <input type="text" name="..." id="..." value="..." />
    

    And you'll only display values to the other users -- no input fields, as they don't have to do any input.


    I suppose you have some way of testing if a user is an admin, either using a database, or a session ?

    If so, depending on the kind of user, you'll use an if statement, to either display the input, or the value :

    // $isAdmin has to be set accordingly
    if ($isAdmin) {
        echo '<input type="text" name="..." id="..." value="..." />';
    } else {
        echo "the value";
    }
    


    After that, of course, on form's submission, you'll do the same test, to only work with $_POST if the form has been submitted by an admin.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!