Jump to content

jeffman

Members
  • Content Count

    7,761
  • 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-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. 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

    time

    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

    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. 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 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. 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 defining one of the height values for the html element.
  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 div has it's top coordinate equal to the height of the header. If it didn't, it would be at the top of the wrapper. That is also why the #content div has margin on every side that contacts a fixed div. If it didn't, it would also be at the top left of the wrapper; at the bottom, its content would be hidden by the footer. So its top margin is the height of the header, bottom margin is the height of the footer, and left margin is the width of the #navigation div. This really is the way margins work under normal circumstances. It just doesn't seem that way when you first look at it. The footer is fixed also, but it has to be pinned to the bottom, not the top. That is why its bottom coordinate is specified rather than the top. The #navigation div has a min-height so that it is guaranteed to fill the space between the top and the bottom. Without it, it would be only as high as its content, which is the UL element. The same trick could be applied to the #content div, but that one uses a more traditional trick, which is to make its background color the same as the background of the wrapper. So if it is ever shorter than the space between the header and the footer, you would not be able to see that. Finally, with all those fixed divs and crazy margins, the wrapper also has to be taken out of the flow. That creates a new "problem." The typical technique for centering it in the page won't work (setting left-right margins to auto. So it is centered by placing its left coordinate at 50% the width of the page (too far, in other words) and its left margin is negative half the width of the wrapper, which pushes it back to the left. All that stuff follows "the rules," but they are not applications of the rules the way they are discussed in most references. Hope that helps. And FWIW, don't be surprised if someone shows up with a whole other set of techniques to get the job done. CSS can be like that.
×
×
  • Create New...