Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. Your problem is occurring because your append method call is destroying the old datepicker input element and adding a new one to the DOM, but the datepicker method call is (likely) setting up a click event handler for the old input, which is no longer in the DOM. Try adding the following line below the append method call (as well as retaining the call you already have): $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
  2. Hello and welcome to the forums. Obviously, there could be a number of factors, but if the DB isn't updating and you're not seeing any PHP errors, then very likely, the issue is with your query. Try echoing the generated UPDATE query string out to your browser, and then copy and paste that into phpMyAdmin or whatever, and see if you can execute the query directly on the DB. Likely, an syntax error will occur. Please let us know what you find. Thank you.
  3. Please look at the following: index.php?=$1 [L] It looks like you're missing a parameter name before the equals sign.
  4. Have you tried running a real simple example of mod_rewrite just to make sure it's properly installed and running on your server?
  5. There's no solution in that that is how posting has always functioned in browsers, so it's more something that people (both devs and users) just have to accept. As you hinted, you can use JS to circumvent things, but that can create other problems too.
  6. Hello and welcome to the forums. Please check out the following: http://stackoverflow.com/a/12461336/1992973
  7. I've seen a lot of sites that put disclaimers near the submit button that say something like the following: "After clicking Submit, please wait a few moments and please do not click the Back button or close your browser." Beyond that, what can you do? At this point in the history of the Internet though, I think that people with slow connections have learned not to hit the Back button, etc. when the submit a form. And if they do hit Refresh or the Back button, what are you going to do if it's PHP only? There really is nothing. I guess my point is, you can only prevent idiots from hurting themselves to a certain point. Beyond that, it's not your concern.
  8. As far as I know, this is the intended behavior and most sites implement things this way. Granted, you could do a redirect, but that will make your code more complex and it seems like you're fighting intended and well-known behavior at that point. If you click on the URL bar and hit enter, it'll reload the page without posting the form. What I can't understand is if you're concerned about this for testing purposes or if you are concerned about your end users. In other words, what's the problem?
  9. I'm not sure what the context is, but if you refresh a page that has been loaded from a posted form, the form will be re-posted. Generally though, your browser will ask you if you want to re-post the form or not in that case.
  10. You can do it either way. I was providing my way more as an example than as actual code that you should implement as-is. (Sorry, I should have explicitly stated that.) Anyway, if you want to do it your way with the array, but by applying the same principle, then what about the following: $pages = array( 'Home' => 'index.php', 'About' => '#', 'Contact' => '#' ); if (!isset(SESSION['user_id'])) { $pages['Register'] = 'register.php'; } This is essentially the same as what you recommended, but it offers more flexibility with any links you may want to add in the future and/or make conditional. Also, you're welcome to question my code at any time. Edit: As a side note, I wouldn't recommend using an associative array (i.e., string keys) when you care about the order of your items (which I'm assuming you do). In all likelihood, PHP will retain the intended order of your nav links, but still, there's no reason PHP has to (after all, JavaScript does not in the same case), so it kind of scares me. The $pages array may be better implemented as follows: $pages = array( array( 'label' => 'Home', 'url' => 'index.php' ), array( 'label' => 'About', 'url' => '#' ), array( 'label' => 'Contact', 'url' => '#' ) ); The structure is a bit more complex, but not unnecessarily so, and you now have ultimate control and flexibility on how you present the nav via your data model. Just my two cents.
  11. Something like the following should get you there: <ul> <li><a href="">Home</a></li> <li><a href="">Link #2</a></li> <li><a href="">Link #3</a></li> <li><a href="">Link #4</a></li> <?php if (!isset(SESSION['user_id'])) echo '<li><a href="">Register</a></li>'; ?> </ul>
  12. Just out of curiosity, where did you take the course? Thanks.
  13. Hello and welcome to the forums. There are quite a few problems with your code that seem to imply that you have a misunderstanding of many of the fundamentals of JS. I don't say that to be rude, but rather to suggest that I'm happy you want to learn how to do this on your own, and assuming that is the case, I would recommend buying Larry's JS book and going through it. It will explain everything you need to know to achieve what you want. Thanks.
  14. It's because you're using single quotes instead of double quotes. Run your PHP and then look at the resulting source code. You'll see that each option element starts with the following: <option value="$key"selected="selected"> Obviously, you don't want a value of "$key", and you don't want every option to have a value of selected, and you don't want the missing space between value and selected. Basically, you have a bunch of mistakes in your code. Change value="$key" to value="' . $key . '". Get rid of the semicolon at the end of the if statement. Add a space before selected="selected". Move the ">" after selected to the beginning of the echo $value statement. That should solve your problem. In the future, if you're having a problem, look at the source code resulting from the PHP code, and look for problems.
  15. You said that your POST array was empty when you posted the form, correct? If that's the case, then that is your problem. You need to figure out how to properly post your form. Start with a much simpler form, and get it to the point where it's properly posting, and then the problem should become clear. If the problem is related to something other than the POST array not being received, then you need to better describe your problem. ...And if you don't even know what your problem is, then you need to first work on better describing the problem for yourself before you try to explain it to us. Thank you.
  16. Please use the <> icon in your editor to better format your code. I'm not going to take the time to decipher your code (and I doubt anyone else will either). If your POST array is empty, then that is your problem. The data is not being properly posted to your script.
  17. You need to grab the input element in the DOM, and then modify the placeholder attribute. If none of that makes sense, I highly recommend checking out a JavaScript tutorial or getting Larry's JS book. Thanks.
  18. Put the following code after where you've confirmed that the POST array is set to check the values stored in it: echo '<pre>'; print_r($_POST); echo '</pre>';
  19. Good find! Might I recommend bubbling this error up to the original GitHub page and earning yourself some GitHub cred while you're at it?
  20. Those errors are very likely a result of your query being invalid. Try running the query directly on the DB, and if that's okay, echo out the values of the variables used in the query to ensure that those are being set to what you expect.
  21. Glad it was that easy. Thanks for letting us know how you solved the problem, too.
×
×
  • Create New...