Jump to content

phppup

Members
  • Posts

    827
  • Joined

  • Last visited

  • Days Won

    1

phppup last won the day on September 13 2022

phppup had the most liked content!

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

4,883 profile views

phppup's Achievements

Prolific Member

Prolific Member (5/5)

2

Reputation

1

Community Answers

  1. @kicken Ahhhh, now I see it. So, with the parenthesis I can receive an input as you described. But without the parenthesis I am successfully limiting the totality of characters submitted to 1+48+1 (adding the first and last). At this point, I'm kinda okay with using only the American alphabet, but still want to accommodate complex names with apostrophes and hyphens (I'm still skeptical of names with underscores; and the few with numerals will need to come up with their own nickname ie:Musk's kid). Thanks for the info
  2. @kicken Yes. I am building a form and want PHP to "scold" users that try to submit junk. (It will be used internally by a staff group that needs to be reliied on and trusted. LOL) I realize the need to sanitize names and was going to simply require a-zA-z to eliminate numbers and characters. Then I realized that there are names with hyphens, apostrophes, and spaces, so down the rabbit hole I went. @requinix which left me with $pattern = "/^[A-Z]([a-zA-Z '&-]{1,48})*[A-Za-z]$/"; Is that the same as yours? Do my parentheses alter the outcome? So I guess, thanks to your assistance, I made progress after all. I just have to be more careful about using cut & paste BEFORE my coffee.
  3. @requinix Ok, I think I got it. $pattern = "/^([A-Z][a-zA-Z '&-]{2,4})*[A-Za-z]$/"; Please tell me if this is the [correct] solution that you eluded to. I moved the opening parenthesis to the middle section. Ironically, I may have inadvertently discovered something, as I altered the range for easier testing (but stumbled upon new conditions). Effectively, this modified range of 2,4 had to affect ONLY this mid-section of the string. So, the first character is [A-Z] And the last is [A-Za-z] So with the mid-section {2,4} a total of 3 characters will FAIL the test but 4 thru 6 pass, and then 7 or greater fails. Of course, a minimum of 1 will elevate the minimum to a total of 3 (if a special character is used) I did notice that 2 characters only (being first and last) will pass, but I imagine that adding a minimum to the last set of characters would correct that. My final solution is $pattern = "/^([A-Z][a-zA-Z '&-]{1,48})*[A-Za-z]$/"; Is this the same as your solution?
  4. @requinix Some deeper testing has revealed an unexpected issue. For test purposes I changed the range $pattern = "/^([A-Z][a-zA-Z '&-]{0,4})*[A-Za-z]$/"; and discovered that while the RegEx seems to have a few holes for what would be allowed, it is NOT returning 0 to keep the minimum requirement at two characters. In fact, a single uppercase A passed the test of acceptance.
  5. Well, of course (!of_course] Now, it's confirmed to my needs, but I still pose the question, since sometimes even testing does not reveal what a more educated eye can plainly see.
  6. Ahhhh, so that's the trick!! I used parenthesis (that seem to resolve the issue) but I'd like to avoid any unforeseeable surprised. $pattern = "/^([A-Z][a-zA-Z '&-]{1,48})*[A-Za-z]$/"; Please check to confirm that this working solution is the most correct implementation.
  7. Trying to utilize this expression $pattern = "/^[A-Z][a-zA-Z '&-]*[A-Za-z]$/"; to take name to start with a capital letter, allow some symbols or space, and then continue with more letters. How can I require the length of all characters be involved to be between 3 and 50 keystrokes? Ice tried {3,50} in several positions but none seem to be making the connection that I want. Thanks
  8. So <form method="post"> will default to a SELF process that is slightly safer than the aforementioned?
  9. Are these two pieces of code equal in risk? <form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>"> and <form method="post" action=""> Do they perform the same action? Are both vulnerable? Best practice to minimize vulnerability? Will using prepared statements nullify a hacking attempt? I was doing some reading and thought I'd ask the experts here.
  10. So what do I need to do here so that CSS will toggle my paragraph on its own?
  11. Just toying with CSS to get a result I've usually used JavaScript to achieve. I want to toggle a paragraph's visibility when a checkbox is clicked. .toggle input:checked { p { display: none; } } Obviously incorrect. Also, are there any pro/cons to using CSS over JavaScript?
  12. I don't think I'm ready to code that at this point. But maybe.... Nonetheless, I've uncovered the <optgroup> tag, which seems to be what I was looking for from the start. And I think that better demonstrates how I wanted to "categorize" the options. Now I'd like to be able to collapse the options so that the initial drop-down is only a list categories, with each category list appearing as needed (iie: onclick) But I am making progress.
  13. @requinix I understand what you're saying, but I think I am simplifying the list by categorizing the items. An admittedly backward example but, imagine you needed to know what was in each of the 42 aisles of a supermarket/Walmart. Before going down aisle 18, you would evaluate whether any of the sub-category items interested you, and the same for each subsequent aisle. If you're looking for cookies, you would skip the aisles containing frozen food and automotive items. Isn't that better than an infinite number of radio buttons? It is also expected that users will use this menu regularly, and (like a consistent shopper) learn where to find the sub-category item easily. My supermarket keeps cupcakes in the bread aisle, and I remember it. A different location (same company) puts the cupcakes in the cookie aisle. In either event, I can confirm that I'm in the right place by checking the signage before trekking up the aisle unnecessarily. That's my thinking.
  14. I'm not sure if this requires a CSS or a JavaScript approach, so hear me out. Note: I've been toying with several coding approaches that will get the job done, but I'm seeking an ultimate answer. I have categories and sub-categories: eg: candy (gum, coco), fruits (apple, orange, pear), meat (burgers, steaks) etc. The user has to select ONLY one item, eg: what did you eat last? My thinking is to have a <select> drop-down menu with category titles. When an option is selected, a secondary drop-down should appear. I've got one very old school method that works by literally populating a second drop-down based on the first dropdown selection. But it needs to be promoted in a separate motion (not a seamless flow). I also have a partial CSS solution extracted from dropdown menu designs (which seems to be more of what I'm looking for). The real obstacle is that most users will be using Smartphones to make they're selections. As an Android user I'm familiar with how a <select> is displayed, yet a CSS menu using <a href> responds more like a webpage (and seems too small to view comfortably). Likewise, if a second tier <select> menu were to cover the phone's screen, there would need to be an easy way to go backwards (in the case of an incorrect category selection). Any guidance or solutions for this?
  15. @kicken Understood. I saw similar solutions but couldn't understand why they were using such a convoluted approach. Now it makes sense. Thanks for the explanation. I'll give it a try.
×
×
  • 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.