vincy vincy - 1 year ago 76
PHP Question

How can I make a textbox readonly for certain users in PHP?

I have a text box on my web page and I want to make it

for certain users in PHP. The following is the code of the textbox which is populated from an array retrieved from database.

<td width="130" align="right" valign="top" nowrap>
<label for="descr">Name</label>:
<input type="text" name="descr" id="descr" value="<?php echo htmlentities($row_product['descr'],ENT_QUOTES,'UTF-8'); ?>" size="50">

I want only certain users to only read the value and not be able to change it.

Answer Source

textareas (and other inputs) have a readonly attribute. You can just put it in the tag for those users that meet the condition. XML compliant: readonly="readonly"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download