Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Newbie - Enable/Disable HTML input elements by login ID

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Newbie - Enable/Disable HTML input elements by login ID

Postby bc56 » Fri Jul 18, 2003 7:19 pm

I am brand new to PHP and am looking for a way to enable/disable the input elements on a HTML form based on the login ID. Is there a function I can use that will disable any input for some users and enable it for others? Can I do this to the entire form and/or to specific elements? I have created the form in various parts so I can manipulate which parts different users have access to view.

Any direction or ideas are greatly appreciated.

Bruce
bc56
New php-forum User
New php-forum User
 
Posts: 5
Joined: Fri Jul 18, 2003 6:36 pm

Postby swirlee » Fri Jul 18, 2003 10:08 pm

The best way to do this is just to make the 'restricted' form elements just not show up. I believe that there is a JavaScript attribute called "disabled" that you can use to "grey out" a form field, but that's very easy to get around. The only way to really keep certain users from filling out certain form fields is just to make them not appear to those users. A simple conditional should do:

Code: Select all
if(user_is_authorized($username)) {
   echo '<input type="text" name="something">';
} else {
   /* show not-authorized message or just do nothing */
}
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby bc56 » Sat Jul 19, 2003 5:29 am

Swirlee,

Thanks for the suggestion, but I really need to show some portions of the form for other users but prevent them from editing some parts.

Basically I have a multipart form that the first user will start to fill out, submit to another user to approve, then go to another user to add addtional info and send to 3 other users for approval and comments. Other than the administrator, I want each user to be able to see previous input, but only edit their portion of the total form. Hope this makes some sense.

Thanks again,
Bruce
bc56
New php-forum User
New php-forum User
 
Posts: 5
Joined: Fri Jul 18, 2003 6:36 pm

Postby Joan Garnet » Sat Jul 19, 2003 6:10 am

You can use the readonly attribute for example.

Or just print the other user's text as normal text and put only the editable part inside a textarea or whatever.
To keep every part (the parts with plain text from previous users) you can add the information into a database keeping track of which user has written it.

Just an idea :idea:
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby bc56 » Sun Jul 20, 2003 8:14 am

Joan,

Thanks for the tip and suggestion.

Bruce
bc56
New php-forum User
New php-forum User
 
Posts: 5
Joined: Fri Jul 18, 2003 6:36 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.