Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Posts posted by HartleySan

  1. I'm glad you went with the second suggestion. I also agree that it's a better solution.

    Also, you are right that (while extremely slim) a query could go between your other two queries and muck things up.

    If you were to go that route, which I wouldn't recommend anyway, then you'd probably want to use a transaction to ensure the integrity of the data.

     

    Anyway, glad you got what you wanted.

  2. The following allows you to get the auto-increment value of a DB table:

    http://stackoverflow.com/questions/15821532/get-current-auto-increment-value-for-any-table

     

    You could use that query as a subquery in your INSERT to set the publicname field.

    With that said though, even though you're only executing one query by doing that, because the query has a subquery, you're still essentially executing two.

     

    Unless you need to index and heavily search on the publicname field, I think a better idea is to dynamically generate the publicname value on SELECT, and never bother with it on INSERT.

    You could either use MySQL's CONCAT function to create it on the DB side, or you could easily create the value on the PHP side. It's up to you.

  3. I think it depends on how you're trying to hack a password. If you're going through a normal web interface, then you would never enter a hash directly. You would enter a regular password, and that would then be turn into a hash and compared to a hash in the DB on the back-end.

     

    If, somehow, you got access to a whole DB of hashed passwords, then yes, you could potentially do what you suggested, which is akin to a dictionary attack, which is a popular technique for trying to crack passwords.

     

    Anyway, I think (and I could be wrong) that a lot of password hashing algorithms these days take the time into account when hashing the password, and somewhere within the hash itself is a key hidden to retrieve that time so that at any later time, you can check that the hash you're creating for confirmation purposes matches the original hash when it should.

    Honestly, I don't know though.

     

    The whole password hashing industry is an incredibly complex one with a deep history that's probably worth reading about.

  4. Your question is a bit unclear, but assuming my understanding is correct, what you want to do is not possible, regardless of the programming language you use.

     

    Probably the closest you can get is to force the browser to download the file, and then let the user open that file directly using either the default suggested program or a program of their choosing.

     

    I think it's important to realize that the web as a whole intentionally does not give websites access to a user's local file system and the programs installed there, as that could lead to huge security concerns.

  5. My guess would be that your form element doesn't have the method="post" attribute, and as a result, the form is being submitted via the GET method, thus causing the $_POST superglobal to not be populated, thus leading to those errors you stated.

     

    Try adding the following code right above where you are attempting to set those four PHP variables to either confirm or deny my suspicions:

    echo '<pre>';
    print_r($_GET);
    print_r($_POST);
    echo '</pre>';

    You can also easily confirm if the GET method is being used by seeing if all the form data is placed in the URL bar as URL parameters upon form submission.

  6. Basically, document.getElementById is a DOM object, not a string. The best way to verify this is to put the following lines of code after your three var declarations in calculate:

    console.log(sentence);
    console.log(keyword);

    You'll see that the console will show you DOM elements, not the strings entered for those inputs.

    Now, if you either loop through the DOM object properties (or more simply, check an online resource), you'll see that all DOM objects that represent input elements have a property called value. Thus, by typing DOM-object.value, you can access the value actually entered for that DOM element.

     

    That make sense?

    • Upvote 1
  7. To download just the PDF, use the readfile function on just the PDF file, not the HTML file.

    There's no way I know of just displaying the cover of the PDF beyond taking a screenshot of the PDF and displaying that, but really, I think it's pretty much a moot point, since all browsers these days can natively display PDF files in their entirety.

     

    Edit: You could create a second copy of the PDF that is just the cover page and link to that as well.

  8. Basically, you never want to assume anything in programming.

    In this case, you're ensuring that comments is not null (i.e., it's a valid DOM element) and that it has the value property (i.e., it's a valid form input element).

     

    If you assume both of those things without checking, then your code would through an error on the comments.value.indexOf part of the if statement whenever comments was not set to a DOM input element.

     

    That make sense?

×
×
  • Create New...