Jump to content

HenryCan

Members
  • Posts

    48
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

HenryCan's Achievements

Member

Member (2/5)

3

Reputation

  1. Thank you, mac_gyver and ginerjm. I imitated the approach you suggested and everything is working fine now.
  2. I want the checkboxes to be INITIALLY checked but if the user unchecks some of them before pressing Submit and then I have to redisplay the form to show error messages in other fields, I need to display the ones he unchecked as unchecked when I display the errors. If I just hard-code "checked" in the checkbox description, I don't see how I'm going to uncheck them programmatically and keep them unchecked on the form.
  3. How do I turn a checkbox on or off programatically? My form has several checkboxes that are grouped together and I want them to be turned on initially when the user first sees the form.I can do that very easily by just including "checked" in the HTML for the checkbox. But if the user turns off the checkbox before he presses Submit, I want to make sure I show the ones that are off as off when I redisplay the form as a result of errors in other fields, like textareas. How do I turn the checkbox off or on within my PHP code?
  4. I'm developing a form which is essentially a simple set of radio buttons. Conceptually, it is like this: Please select a theme from the list: o Black o Blue o Red [submit] [Reset] I'm actually showing a slideshow of images showing the appearance of each of the themes in a slideshow that only shows one image at a time. I want my users to click on the image that represents the theme they want and, ideally, not have to click on the Submit button at all. Then I will save the name of the theme they chose in a cookie (if cookies are enabled). Many years ago, I dabbled in things like CGI and I have a vague recollection, possibly faulty, that it's not difficult to make a form that has only one set of radio buttons treat the selection of one of the radio buttons as a Submit. I don't remember how to do it though. Can anyone advise me on whether it is indeed possible and, if it is, how I make the selection of the radio button cause the form to be submitted?
  5. Please see my reply to Davidannis. I really don't want to bring JavaScript into the situation since some visitors will certainly have it turned off. I think your approach would make me send the visitor to the Preferences page if he hasn't already set some Preferences and I'm reluctant to do that. Also, what do you mean be having one cookie be an array with all the settings? Is there some reason that a single complex cookie is a much better choice than several simple cookies? And aren't I going to run into issues with the max cookie size of 255 bytes? (At least I think that's what it was back in the early days; perhaps it has been increased in recent years.) I don't actually know how much data I will have to save yet. I'm prototyping a design of my own creation. I may end up letting my visitors choose preferences for a whole bunch of things or maybe just a small handful. It depends on the feedback I get as I test. If they want more control, I'll have to save more data. Multiple simple cookies, each with a clear purpose, seems a little easier at first glance than having to make up a lot of very short codes for everything (assuming many values to be saved) and then packing and unpacking/parsing all of that information once I retrieve the cookie. But that's just an initial reaction. I'm open to trying to cram everything into a single cookie if there is some large benefit to it.
  6. Please see my reply to Davidannis. I don't think I'm likely to generate enough preferences to need a database table. In any case, I'm not awfully worried about database work; I've done lots of that. Some of it was even with PDO and MySQL, both of which are available in my current environment ;-) Hmm. Am I understanding you correctly? Are you proposing a database table INSTEAD of cookies? Or are you suggesting them as a supplement to the cookies? If the latter, what is the table going to do that the cookie doesn't?
  7. The gist of it is that you can't fetch a newly-created cookie immediately after creating it: you have to send a new batch of headers before you can possibly see the new cookie. These are the top two search engine hits to my question: http://stackoverflow.com/questions/6663859/check-if-cookies-are-enabled -and- http://stackoverflow.com/questions/9448424/detect-if-cookies-are-enabled-in-php All the replies seem to get criticized for something or another, although I may be misunderstanding what I'm reading. As for your suggestion, I'm struggling a bit with how to distinguish between the case of: 1. no cookie has been set because the visitor has never been here before 2. no cookie has been set because the visitor has disabled cookies (or someone did it for them and they don't realize they are disabled) I'd like to avoid offering the visitor a Preferences page if it isn't possible for me to save those preferences in a cookie. If they arrive on the Preferences page on their own, I'd like to be able to write code that tells them that cookies are disabled so they will need to enable them before trying to save any preferences. I'd show that message right at the top in bold different coloured text so they couldn't miss it and would probably disable the Submit button as well, only re-enabling it if they can actually save a cookie. I'd rather not force visitors to go to the Preferences page if I can avoid it. Most of them will be perfectly happy with the default values that get set if no Preferences have been selected. I don't want to pressure them to enable cookies just so that I can store Preferences that are identical with default values. I certainly don't want to keep nagging them on every page that cookies are turned off and they should turn them on since many visitors will want to go with values that aren't the default I'm fine with giving them default values if no cookies exist because they haven't been to the site before and haven't chosen any Preferences. I'd rather not force everyone to go to the Preferences page, even if all they have to do is click Submit to save the defaults. However, I might be arm-twisted into going for that if it's the only reasonable way forward.
  8. I want to give the visitors to my site the option of setting certain preferences and remembering what was chosen from one visit to the next. They might have the choice of setting the backgrond colour of the web page or the font or whatever. I've already written and tested code to write standard cookies that preserve their choices. However, I'm wondering if that's the best way or if there is a better approach. I don't want visitors to have to re-choose their preferences every time they arrive at the site, which would appear to be the result of using a session cookie stored on the server. If standard cookies ARE the best solution for my situation, how can I test if the visitor has cookies enabled on their browser? I know that some people definitely don't enable cookies and I'm quite prepared to advise them that they won't be able to save preferences until they enable cookies. However, I first need to know how I can tell definitively if cookies are enabled. Most of the simple code examples I've found by googling simply try to write a cookie and then try to read it; if both succeed, they think the they've established whether cookies are enabled. The more sophisticated examples, particularly those at stackoverflow, come closer but all of them seem to be critiqued by someone to the effect that they won't work in this or that particular situation. Given how long cookies and PHP have been in existence, I have to believe that SOMEONE has figured out a definitive way of testing whether cookies are enabled that works in all reasonable circumstances. Can anyone share that technique with me?
  9. I may be jumping the gun a bit in giving the Ch0cu3r a "Best Answer" for his reply but it will definitely get me started. Thank you for suggesting this tutorial. I've only skimmed it but it looks like it will cover the necessary ground.
  10. I'd like to write - or acquire - code that displays a simple table (name, phone number, email address, plus a comments field) on a web page in a password-protected page and allows a user to add his own information, update it or delete it. I figure hundreds of people and companies have written something like this so I'd like to find either an example I can imitate or even an existing package that I can simply customize to the specifics for my own table. Can anyone help me with that? Or am I going to have to reinvent the wheel for the gazillionth time and write it myself?
  11. I'm an experienced programmer with several languages (COBOL, REXX, Java, Javascript, etc.) under my belt over many years but I know very little about PHP. I dabbled in it a bit a year or two back and got it to do what I wanted to do but I'm not sure how to do what I currently need. A bit of context: I have designed a website where the user can choose between various page styles; each style invokes different CSS to give them a different visual experience of the site. They can select the style they want via View/Style in Internet Exploder and View/Page Style in Firefox but that preference is only remembered as long as they're on that page. As soon as they move to another page on the site, they have to choose the alternate style again or live with the default style. I want them to be able to select that preference ONCE, the store it in a cookie specifically for them, then keep using that style every time they visit the site. (Naturally, I want them to be able to change the style and then remember the new style as well.) There will be many visitors and each will want that same capability. I currently don't require any login to the site. (I'm toying with password-protecting some of the site down the road but that's not a factor in this page style thing that I'm talking about here. Now, my questions. I've found a variety of short articles describing how to use setCookie() to create the cookie (and delete it later) and getCookie() or the newer echo $_COOKIE["name"] to determine the cookie value. However, I am NOT seeing anything that says where I put the code to set and/or read the code within my web pages. I would really appreciate an explanation of that! I expect to write short fragments of php code to do those jobs which I will then imbed within my web pages via SSI (Server Side Includes). Is that reasonable or is there a better way? Also: 1. When the user clicks on the desired Style in the View/Style menu, how do I detect what choice they made? 2. Should the name of the cookie be something like "pageStyle" or should it be something that uniquely identifies the user so that the right cookie is retrieved when the come back? If the latter, what value should I use and how should I obtain it? I assume that something unique about the user obtained from their headers is far better than displaying a dialog and asking them for some unique identifier. I'd rather stay away from Javascript in any of this functionality since I can't rely on it being turned on. One quick aside while I'm here. Does anyone know how to change the page style if visitors use Google Chrome or Opera? I can't even FIND options for changing the page style in my copies of those two browsers and both are current versions. Do they not support differing page styles at all or do they just hide the technique to choose the style very effectively? -- Henry
  12. I agree with trq. Mind you, I used to teach Database Design (for money) and the best approach for many-to-many relationships is to build an association table, sometimes called an intersection table. I've never heard it called a binding table before but I'm guessing it's the same thing. In any case, it would look like this, assuming you have a real many-to-many relationship. In other words, if a given product could be in many stores and a given store could have many products, which would be the way most retail chains work, you'd organize the tables like this: PRODUCT Table: one row for each distinct product - primary key = product_id Product_ID Product_Description 1 Toaster - 4 Slice - Hamilton Beach 2 Computer - Laptop - Model K54N - ASUS 3 Bicycle - 10 speed - Schwinn STORE Table: one row for each store - primary key = store_id Store_ID Store_Location US1 West Valley Mall - Fresno - California UK1 27 Hilldale Lane - Brighton - UK DE1 Meyerstrasse 15 - Berlin - Germany [Note that the description information in the PRODUCT and STORE tables is likely going to be more elaborate and broken out into several columns but the key thing is that there will be a primary key consisting of something that uniquely identifies each product or store.] Then, your association/interesection table. PRODUCT_STORE table : one row for each store in which a given product is carried - primary key = product_id || store_id Product_ID Store_ID Quantity 1 US1 50 1 DE1 10 2 UK1 20 2 US1 85 3 US1 14 3 UK1 27 3 DE1 15 [Note that I've added some extra data that doesn't belong with either the product or store directly just to show you how useful that association table can be. The quantity represents how many toasters, bicycles or whatever are situated in each store. It's the inventory so that a customer can determine if you have that item in a given store in sufficient quantity for him to buy as many as he needs. (I'm picturing a guy who wants to buy several laptops for his business rather than just one for himself.) It's important to note that the quantity is not the quantity of all laptops or bicycles that your company owns, just the number that you have in a given store. But if you want to know how many you have in your whole chain, you can easily add them up from the information in the Quantity column.] It's not that putting a concatenation of locations on the product table is impossible but it's a heck of a lot harder in the long run. A professional database designer MIGHT go the way you want to go if the costs and benefits make it a reasonable approach but that isn't going to happen that often. Professionals are pragmatists and may choose not to employ full normalization of data but only if they do a proper cost-benefit analysis that says it makes sense to go that way.
  13. Sorry, Jonline, your last remark is not completely clear. Am I correct in understanding that if I simply wait with writing the </body> and </html> tags until I have nothing more to write, everything will be fine? Or are you saying it's already fine the way it is now?
  14. I'm happy to tell you that I have an answer and it's mostly good news. According to a guy at IBM's Toronto Lab, where they develop DB2 for Windows, Linux and Unix, you CAN access DB2 iSeries data via PDO. That's the good news. And since you're getting it from a guy at the Toronto Lab who works for IBM, I think you can be quite certain that this is an accurate answer, not just someone indulging in wishful thinking. The only wrinkle is that you apparently need to use DB2 Connect to accomplish this. I have only a very vague idea about what DB2 Connect offers and what it costs but I've found you a web page that gives you some basic information and lets you request a quote. That way, you can figure out if it is worthwhile to buy DB2 Connect or if it is better to just stay with ODBC which you seem to be able to do without buying any other products. Here's the link to DB2 Connect: http://www-142.ibm.com/software/products/us/en/db2connfami/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.