Jump to content

jwilliam

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jwilliam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Try this: <script type='text/javascript'> var search = new Array(/\076:O/ig, /\x3e:O/ig, /\>:O/ig); var replace = new Array('XYZ','xyz', 'abc'); var s = "Hello Mr. >!"; s = s.replace(search[0],replace[0]); s = s.replace(search[1],replace[1]); s = s.replace(search[2],replace[2]); document.write(s); </script> The replace() method returns the result... it does not apply it to the string automatically.
  2. That's because courseMaintance is not a direct child of document. The easiest way to access the select (but not the most efficient... fyi) is to do something like this: var select_menu = document.getElementById('courseMaintance');
  3. This is the way I do it, but you'll need to be on a linux server with Image Magick installed: $command = escapeshellcmd('identify -format "%wx%h" ' . $path_to_pdf) . '[0]'; $geometry = `$command`; list($width, $height) = split("x", $geometry); Then you can access the dimensions through $width and $height.
  4. Maybe something like this: SELECT * FROM table ORDER BY timestamp DESC LIMIT 1;
  5. You can't begin php variables with numbers. Instead of $1 use something like $var_1.
  6. I don't think you should be "flamed" for what you said. In a large number of cases, I think you're right. For small pieces of html that need to be inserted in the document... just send the html itself. But there are quite a few situations where sending data back in xml format or JSON (my preference) makes for a much nicer user experience. Here's one real-life example. I had an app that had a fairly large form that showed up from time to time. I decided to just generate the html code for the form on the server side and send it back to the app via ajax. The end result was a very jumpy transition and much more bandwidth than was needed vs. a fairly simple javascript method to take the necessary data and dynamically create or populate the form via the DOM.
  7. Are you connecting to the mysql database correctly? Why don't you post the code that you use to do this?
  8. Try using something like this: mysql_query($change) or die(mysql_error()); That may give you more information about your error.
  9. You'll have to use Javascript to achieve this. Buttons have a 'disabled' property, so when you initially load the page print your button like so: <input type="button" id="my_button" disabled="disabled" /> Then, write a JS function to toggle the input's disabled property every time a user clicks the checkbox. I won't write out the full script because I'm about to watch a football game, but you can enable the button in javascript with a line of code like this: document.getElementById('my_button').disabled = false;
  10. Yeah, you're on the right track now, I'd say. You're authentication algorithm could be something like this: On all password-protected pages: - check to see if they're logged in - if they are, check the last time they logged in - if that was more than two hours ago, log them out and send them to the login page - if they aren't, send them to the login page
  11. You should only perform the authentication when the form has been submitted. You can do that like this: if(isset($_POST['submitinfo'])) { /* perform authentication */ } Also, you've got a pretty major security flaw in your authentication algorithm. Any time you take data from a user and query your database with it, you need to "scrub" the data first. If you allow the user to enter anything they want in your login form without cleaning it then I could enter something like this as my username: ' OR 1=1; -- Then, when my username data is inserted into your mysql query, it looks like this: "SELECT * FROM users WHERE username='' OR 1=1; --' AND password='whatever'" By doing that I would now have access to your password-protected pages. Luckily, this is easy to handle. To "scrub" the data you need to pass it through mysql_real_escape_string() so... $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); That's it. $username and $password are now safe to use in mysql queries. Form more info on this Google "mysql injection attacks."
  12. I'm a little confused by your code. As far as I know there is no mysql_getall() function. Just make your query: $sql = "SELECT whatever FROM whatever WHERE blahblahblah;"; $result = mysql_query($sql, $link); while($row = mysql_fetch_assoc($result)) { // print whatever... } That's a pretty standard way of querying your database
  13. If you want to run a script every two hours on a *nix platform (I'm not familiar with IIS) you need to use the crontab. If your hosting provider doesn't allow you access to your crontab then you may want to consider switching. However, I'm not sure your approach to session handling is on the money. If you run a script every two hours to change the 'logged_in' field to 0... and I logged in five minutes before the cron script ran then I'll be logged out for no apparent reason. I would think about a different approach to session handling.
×
×
  • 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.