jeffman

Members
  • Content count

    7,761
  • Joined

  • Last visited

  • Days Won

    26

jeffman last won the day on July 25 2013

jeffman had the most liked content!

Community Reputation

86 Excellent

About jeffman

  • Rank
    Not really back

Previous Fields

  • Languages
    Specializing in: HTML, CSS, JavaScript, PHP

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
  1. Some of the examples in the manual should help.
  2. Dave is 100% correct. Suggested reading.
  3. 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-character string, the expression makes sure that the 9 characters fall between the exact ^beginning and the exact end$ of the string. The i at the end allows the letters to be uppercase or lowercase.
  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 some cases (long explanation) it's the only way to output a string without creating a lot of trouble.
  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. 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. 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. php

    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. You can format any address so it looks like this: Real Name <user@domain.com> You must pass that entire string, already formatted.
  12. 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. 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 you send some UTF characters, it sends another kind of Content-Type header. And if you send any HTML at all, or an attachment, or any combination of that, everything gets very complicated. This is why a lot of developers use Pear. When you study the raw source for each kind of email, you can get a good idea how to format your own messages and headers. It's one thing to read the rules in the manual. It's another thing to read the specification. It's another thing to read tutorials. Seeing it done for real helped me understand it much better. (Tutorial authors almost always make an important mistake or forget to tell you something important.) I also compared what I learned by studying the raw source generated by a different email client. Some things, there are multiple ways to get a thing done. Other things, you have to do it exactly the same way every time.
  14. 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.