繁体   English   中英

在PHP中向随机用户显示html内容

[英]Displaying html content to random users in PHP

我正在尝试为PHP中具有特定ID的用户启用Web表单的输入元素,当前这里是动态html内容:

<input type="text" name="you" placeholder="only user with the following id can see this, sorry." disabled>

以下是仅针对所选用户激活的代码:

 function chkboxClick(chkbox) {
        chkbox.nextSibling.nextSibling.disabled = !chkbox.checked;
    } // Checkbox appears asking user to check to enable input

我不是专门选择用户,而是尝试选择随机用户。 基本上,数据库中有一个表或某种形式的代码,它们可以随机选择一个用户,并将“ YoureTheOne” ID分配给激活上述代码的用户。 如何创建将ID随机分配给用户的表/代码?

要显示该文本区域的用户的ID

假设

$array_id = [12,14,15,18,19,22,25];

if(in_array($current_user_id,$array_id)){
    <input type="text" name="you" value="your text">
} else {
    <input type="text" name="you" placeholder="only user with the following id can see this, sorry." disabled>
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM