简体   繁体   中英

Displaying html content to random users in PHP

I'm trying to enable the input element of my web form for users with a certain id in php, currently here is the dynamic html content:

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

Here is the code that will activate for only the chosen user:

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

I'm not specifically choosing a user, I'm trying to choose a random user. Basically there is a table in the database or some form of code which randomly selects a user and assigns the "YoureTheOne" id to that activating the above code. How do I create this table/code which randomly assigns the id to a user?

put id of that user for that you want to show textarea

suppose

$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>
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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