Take the 2-minute tour ×

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 :)

share|improve this question
i wouldn't even show it, disabling it confuses some people –  Dagon Mar 22 '11 at 5:32
Hm.. What if the users only want to see my allowance for this week? I want to make it not editable so they can only check my allowance. Do you have any advice or alternative? :) –  catsgirl008 Mar 22 '11 at 5:35
form input fields are designed for, well, input, when you start messing with such basics it can really mess people up. display the editable form inputs to you, and just echo the text for the user –  Dagon Mar 22 '11 at 5:43
add comment

3 Answers

up vote 1 down vote accepted

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) {
} 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.

share|improve this answer
Very noice! :) I'll try this now. :) Thanks Pascal Martin :> –  catsgirl008 Mar 22 '11 at 5:36
I recommend this methodology. No sense making an input when no input is needed. –  Phoenix Mar 22 '11 at 5:37
add comment

Check to see if you are not logged in, and if so, add disabled="disabled" to the input and throw any POSTs that attempt to update data.

share|improve this answer
Okay, will try this one now. :) Thanks! :D –  catsgirl008 Mar 22 '11 at 5:31
add comment

I too like the idea pointed out by Pascal MARTIN and Phoenix....

But still if are looking for disabling the textbox or textarea we have two options for it...

1) disabled="disabled" add these option to the required textarea or text field

2) readonly="readonly"

where option 1 only allows user to view the content....

option 2 allows users to view the content as well as copy it ....but cannot modify it.................

share|improve this answer
Option 1 is what I'm into. Thanks. :) –  catsgirl008 Mar 22 '11 at 6:58
add comment

Your Answer


