OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Read-only form fields

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Read-only form fields
Page: [1]
 
womble

 

Posts: 6007
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
Read-only form fields - 10/30/2009 12:47:48   
I have a database (MySQL) that's displaying data in what was just a table. To explain a little, it's an application where users can store lists of books they've read, want to read, etc., and the database is searchable, to allow users to find books others are reading that match their reading tastes. I need users to be able to be able to add a record for a book they've found through the search to their own reading list.

The only way I could figure out to be able to do it was rather than display the data in a table, to display it in a form, but only make the data read only. I found I could make the input fields read-only by putting "readonly" in the fields, which works fine to make the fields un-editable (obviously I don't want users being able to alter other users' records :)), but with the 'readonly' in there the pages don't validate. Anyone any idea if there's any way of doing it that's valid?

_____________________________

~~ "A cruel god ain't no god at all" ~~
~~ Erase hate. Practice love. ~~
Giomanach

 

Posts: 6187
Joined: 11/19/2003
From: England
Status: offline

 
RE: Read-only form fields - 10/30/2009 13:57:31   
Two Options. Both use the PHP session lark.

Use the PHP sessions to match the username to the list - if it matches, display an "Update" button. If not don't. Use the PHP to do this though.

-or-

Same again, use the session to check the username. If it matches, use the PHP to load a form, if not, use it to load a table format layout of the users data.

Ya know, something like:

<?
$usersession = PHP_SESSION('username');

//Have SQL here to pull requested datas attached username etc

$datauser = //Username pulled from DB that relates to records being pulled ;

if ($usersession == $datauser){ //Does the session username match records being pulled username
    //If it does - SQL/PHP to display form
}
else
{
//If not - Pull same data from DB but in table format layout
}
endif
?>


_____________________________




(in reply to womble)
womble

 

Posts: 6007
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: Read-only form fields - 11/1/2009 5:54:06   
Thanks Dan - I'll have a look into that. Apart from solving the readonly problem it looks like that might be a more efficient way of doing it than I'm using now.

How it's set up at the moment, for the part where the user can search the entire database rather than just filter their own list, there's no option for them to be able to edit a record if the search turns up something on their own list and they then decide they want to update the record (the app allows them to set a status on an item (whether it's something they've read, started reading, want, etc.) and also rate it, as well as enter brief notes on the item). If they wanted to edit one of their own items they'd have to go back to their own list, find the item again, and then edit it from there.

In the meantime though, and for the benefit of anyone with a similar problem that comes across this, I accidently (was looking for something else at the time :)) found a way of getting around the validation issue with forms. Turns out that it's the shorthand 'readonly' that the XHTML validator doesn't like.

If you have a form input field like so:

<input type="text" name="text id="text" value="blah blah blah" readonly />


...the validator says, "Nooooo! That's horrid!" (or something like that :))

....but if you do this....

<input type="text" name="text id="text" value="blah blah blah" readonly="readonly" />


...the validator likes that much better. :)

_____________________________

~~ "A cruel god ain't no god at all" ~~
~~ Erase hate. Practice love. ~~

(in reply to Giomanach)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Read-only form fields
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts