Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. Every time a new page is loaded, store the time in a session variable, and then check that it has not exceeded a certain limit since the last time a user has viewed a page. For example: function checkTimeout($timeout = 600) { if ($timeout !== 0 && isset($_SESSION['last_time']) && time() - $_SESSION['last_time'] > $timeout) { // Log user out. } $_SESSION['last_time'] = time(); } Note that the above defaults the timeout time to 10 minutes, but it can be set to whatever you want, and by passing an argument of 0, no timeout will ever occur.
  2. Antonio is right in that it is very trivial for someone to submit to your PHP script from anywhere any which way. As such, you have to assume that any text can come in any way, and you need to guard against that accordingly. If you are expecting a number, simply typecasting the submitted value as an integer or float with (int) or (float) accordingly should be more than sufficient. However, if you are expecting text and you are going to display that text back to users in one form or another, then you should absolutely use htmlspecialchars or whatever. As a side note, because numbers are much easier to validate and less subject to funny business, I try to make as many things number inputs as possible.
  3. Please read my previous post. The resulting markup did not match the displayed image at all. I don't want to see the PHP code, I want to see resulting markup and CSS, and an accurate picture of the problem with the corresponding markup. Thank you.
  4. That markup would not produce the problem in your original post. Your original post has 1, 2, 3 and "Next", which your markup does not. Please post the markup with the actual results it produces. Thank you.
  5. What value is required for a user to be "activated"? Is it null? Some other value? Whatever that value is, insert it into the users table when you perform an insert on that table. That make sense (or am I still misunderstanding your question)?
  6. Run an insert on the DB and set the activation code to null (or whatever value is "activated"). Send an email via PHP that grabs the activation code from the DB and adds it to the email.
  7. asanti, please look at my question in my first post again and answer it in kind. Thank you.
  8. Hello and welcome to the forums. It's very likely a CSS issue. Please post your generated HTML markup and related CSS. Thanks.
  9. As an American that lived in Japan for a long time, I fully agree with Antonio that it's better to ask than to assume. For the sake of a selection, if you want to default to something based on an educated guess, that's fine, but whatever you do, make it easy and obvious to switch the country/language at any time.
  10. Hello, and welcome to the forums. Yes, your assumptions are correct. The rendering loop occurs so quickly that even though the loop is re-rendering each task every time you click the submit button, it happens so quickly, that your eye only perceives the final task being added to an existing list of tasks, which is in essence the intended effect.
  11. kamaboko, that code snippet in your previous post is designed to handle cross-browser variances. Specifically, whenever an event occurs for a DOM object, the associated event listener method (i.e., function) is called, and the Event object is automatically passed to the event listener method as the first parameter. Traditionally, people call this parameter "e", "evt" or something similar (because it's the Event object), but really, you can call it whatever you want. Normally, that would be all you need to go about your merry way, but unfortunately, old versions of IE (<= IE8) do not support the Event object being passed to event listener methods. As such, to make your code work in all browsers, you have to check if "e" is defined or not, and if it isn't, you know you're in old IE, in which case, you can then access the Event object via window.event. Once you have the correct Event object, you then need to use that to get the correct event target, which, as you have probably guessed, has two ways of being accessed: the standard and the old IE way. The standard way is Event.target, whereas old IE is Event.srcElement. (Note that Event in the previous sentence is the same thing as "e" in the code snippet.) The last thing that might be causing you confusion is the || operator. The || (logical OR) operator in JS allows you to quickly get a value by first checking the value to the left of the ||. If that value exists (i.e., it's not undefined, etc.), then that value is used. Otherwise, the value to the right of || is checked for its existence. It's basically just a quick way of checking which value exists and assigning that to the variable. That all make sense?
  12. You need to use the move_uploaded_file function to both name the file and specify the file path for the file. Details on the function can be found here: http://php.net/manual/en/function.move-uploaded-file.php Basically, post the form, and in the PHP script that is called from the form post, used the specified values to name the file. For example: move_uploaded_file($tmp_file, "/uploads/file_{$_POST['category']}_{$_POST['class']}_{$_POST['title']}");
  13. I totally agree with you, Edward. You don't have to justify to me why you are going with one solution over another. If something saves you three months of dev time, then obviously, that's worth it, and I'd do the same thing. Also, I think the reason I am usually able to figure out a problem someone is having is because it's kind of a, "Been there, struggled with that," sort of thing. Most of the problems people have had, I've had as well, so I can usually relate, which helps a lot. Anyway, best of luck with your site, and it sounds like you're learning a lot in the process.
  14. I totally believe that, but I would also think that for the HTML-format version of a book, you'd want to autogenerate the HTML page on the fly (e.g., pull some text with some form of markup from the DB) when the book was viewed from the web.
  15. 7 MB is still insane for an HTML file, but a good start, nonetheless. Thanks for sharing.
  16. Just out of curiosity, where did this 70 MB HTML file come from, and what did you need to edit it for? It sounds insane. Thanks, and welcome to the forums. You've provided some great answers to other people's questions.
  17. Please use the MySQLi (notice the "i") family of functions, not the old and out-of-date MySQL functions. After that, add the following code below where you set up your DB connection to make sure that it's okay: echo '<pre>'; print_r($con); echo '</pre>';
  18. I would just use the built-in in_array function to check whether a value has been selected or not. For example: $all_skills = some-array-with-all-of-the-possible-skills; $selected_skills = another-array-with-only-the-selected-skills; foreach ($all_skills as $skill) { echo '<option' . (in_array($skill, $selected_skills) ? ' selected="selected"' : '') . '></option>'; } Of course, you need the extra markup for the option text to be displayed, and the actual select element itself, but I wanted to keep the code simple for the sake of focusing on the key point.
  19. "obj" can refer to any valid DOM object, not just the document object. With that said, there is often a huge performance benefit to attaching only one event listener to the document object and then checking the event target as opposed to setting up lots of individual event listeners for each of the actual DOM objects you want to listen to events for.
  20. chop, which jQuery carousel plug-in/method are you using? Please provide a link. Thank you.
  21. Beltic, certainly, anything is possible, but I think it might be best to look around the web and see what other people are doing. Here are a few ideas: Provide more results per page. Do what Larry suggested, which is calculate the total number of pages, and then calculate the middle, or allow jumping to 2-3 pages on both sides of the current page, etc. Provide a search feature or filters that allow the user to find what they really need. If you really have so many rows that you have that many pages, no one is going to search through all of that for what they need. As such, some sort of searching/filtering is necessary, I think. Thanks.
  22. Sorry for the ultra late (and now likely useless) reply, Edward. There was a long period of time where I was on these forums daily (usually multiple times a day), but over the past few years, I have slowly grown out of these forums. I still love all the people here and all the help Larry has provided me with over the years, but it just feels like it's time to move on. Besides, there are still lots of great people on these forums to help out. I imagine that I'll still once every month or so stop by to look for any topics that pique my interest, but I will no longer be contributing at nearly the level I used it. Please be sure to let me know how your site is coming along though, and I will try to read up on it and respond in kind when I'm around. Thanks.
×
×
  • Create New...