Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by jeffman

  1. Some of the examples in the manual should help.
  2. Dave is 100% correct. Suggested reading.
  3. jeffman

    If else statement

    Birbal is correct. Since regular expressions are not easy to learn, I have written one that will do your job. I suggest you study regular expressions if you need to validate a different kind of string. function validates ($str) { return preg_match("/^[a-z0-9]{9}$/i", $str);}// USE IT LIKE THIS:$s = "abcd12456";if (validates($s) ) { echo "Yes";} else { echo "No";} /^[a-z0-9]{9}$/i is the regular expression. It makes sure that all the characters are letters [a-z] or digits [0-9]. It makes sure the string is 9 characters long {9}. Since a 9-character string can be part of a 10-
  4. Notice that document.write() comes after the for-loop in the first example, but inside the loop in the cars example. So in the cars example, a string is output every time the loop iterates. In the first example, x is a string that gets longer with each iteration (we call this concatenating), and its value is not written until the string is completely concatenated. x is needed in this case as a place to store the string as it gets longer each time. Strictly speaking, concatenating a string and outputting it just once is slightly more efficient than outputting a series of strings, and in som
  5. The problem is your conditional: if (div_1.style.display == 'block' || div_1.style.display == '') When the page loads, div_1 displays none, so the first test returns false. But style.display IS an empty string, so the second test returns true. Change your conditional.
  6. As explained here, you must clear out the $_SESSION variable also.
  7. jeffman

    * Selector?

    My display at home is 1080px high. According to W3Counter, almost 20% of displays are in that range, and they're bound to get more common Seeing a footer in the middle of my screen always looks incredibly dumb to me.
  8. How are you updating the page? Are you sure this is a javascript question and not a server-side question? Are you using AJAX or a traditional form submission?
  9. jeffman


    strtotime("2013-07-19 16:36:18"); This will return a Unix timestamp. Timestamps are given in seconds. From this timestamp you can subtract 60*60 seconds and create a timestamp one hour earlier than your previous time. With that, you can use date() to convert the new date to any format you like. With new versions of PHP, you can also use the DateTime class.
  10. jeffman


    Most servers are configured so they only execute PHP if a file has a .php extension. You should be able to change this setting in a control panel somewhere. I do not recommend this. If your server has to read every .htm or .html file and look for PHP code every time, your server's performance will degrade.
  11. jeffman

    mail function

    You can format any address so it looks like this: Real Name <user@domain.com> You must pass that entire string, already formatted.
  12. jeffman

    bugs in php tutorial

    Both are legal in PHP. There is a small difference that you can read about here. There is also a widely used set of coding recommendations out there that says this: I personally ignore a lot of those recommendations, but if you are ever employed as a developer, you may be required to use them. (You might also be required to use a different set, too.)
  13. jeffman

    mail function

    FWIW, mail is tricky. If you get beyond simple messages, you might want more help than the usual sources give you. Here's a trick I used. With a mail client like Thunderbird, I sent messages to myself. Thunderbird is good because it lets you view the raw source of your email -- the parts you see and the parts you don't see. Other programs do this too. Thunderbird is just an example. One thing I learned is that the email client uses different header values depending on different circumstances. For example, if all your characters are plain ASCII, it sends one kind of Content-Type header. If
  14. jeffman

    contact form

    Yes. This is good user interface. Users hate it if there's no confirmation.
  15. Unless you're doing something else you haven't mentioned, comment tags like that have been obsolete for 10-12 years.
  16. Sorry for the misunderstanding. I did want to help. I posted a long response. When I thought your problem was solved, I deleted the text because the forum does not allow me to delete the post. So I tried to explain why my post was there but didn't say anything. Anyway, when I execute your code in Firefox, it creates a table, and the inputs accept text. When you say the inputs don't accept text, do you mean that when a user types, nothing appears? If a user clicks on the input, does the cursor begin to flash there? It would be helpful if you post all the code or a link to your page.
  17. Ignore this post. I see from your other thread ON THIS SAME TOPIC that the problem is resolved.
  18. This is one of those things where jQuery can simplify your code a lot.
  19. Where you are using the word "and", use the logical and operator instead: if (X==" " && Y==5 && Z==6) { For what it's worth, the logical or operator looks like this: ||
  20. You don't have to do any server-side processing to use AJAX. You can get data from an XML or plain text file that already exists. In fact, that's a good way to test out the javascript side of the technique.
  21. I'm pretty sure Dave knows what the html element is. The html selector is seldom required because applying most CSS properties to the body element does the trick. Typically, if the html selector is used, it's so designers can apply height and min-height properties to the html element, and they normally apply the same height properties to the body element when they do so. In most cases, you would not define a font (for example) for the html element but not the body element. So it's usually quite harmless to combine the html selector with the body selector; all you're doing that's useful is
  22. Unless you are already proficient at using a server-side language like PHP, you are not ready for this. You should run through a basic PHP tutorial first, and either and XML tutorial or an SQL tutorial so you can save your registration data.
  23. You should be able to add background images to any of those elements. The real trick is that the top, left, and bottom divs are all fixed, so they don't scroll when the rest of the page scrolls. If you add a background image to the body element, you will see that everything else scrolls, not just the content div. Fixing a div creates problems that must be corrected. First, those divs no longer expand horizontally to fill their containers. So even if a div stretches from one side to another, you must define the width. Second, fixed divs are taken out of "the flow." That is why the #nav
  • Create New...