Jump to content

Dilated

Members
  • Content Count

    198
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Dilated

  • Rank
    Member
  1. Dilated

    Please check this

    You need to set the cookie after the form is submitted, and you also need to grab the form data that is input using the $_POST superglobal e.g.if (isset($_POST['submit'])) { setcookie('name', $_POST['yourname'], time()+604800, '/'); echo ' your name successfully saved ';} This will get the name that was input and put it into a cookie which lasts for a week.edit: There are also a couple of parse errors:The first piece of code you posted should be: if (isset($_COOKIE['name']))echo 'WELCOME'.$_COOKIE['name'].'<br/>';else echo 'WELCOME GUEST<br/>'; You were missing brackets and
  2. Yes, I mentioned this above but I don't think I stressed it. Be prepared to code a backend and myriads of XHRs.
  3. Honestly, I've never worked with the canvas element personally. I've only seen demonstrations of its wonders. Sorry I can't be of more help, but the mozilla doc center is usually great at providing documentation and tutorials. Here's the canvas tutorial there: https://developer.mozilla.org/en/canvas_tutorialKeep in mind this is a relatively new technology. People will need to be using a modern browser in order to see your canvas element.edit: Also, if you want a quick example, the example the html5 spec gives is: // canvas is a reference to a <canvas> element var context = canvas.getCo
  4. ShadowMage is right, the whole point of the "print" media query is so that you don't have to create a new page.
  5. Yes, it could be done only using html, css and a serverside language, but it wouldn't be very responsive (imagine using a no-JS version of Google Maps). It depends on how advanced/complex you want it to be. You'd probably want to use JS. If you want to do something innovative, you could look into using the <canvas> element.
  6. Dilated

    Cacheing

    Well, like I said, if you have access to the Expires module you can use that along with ETags. Personally, I think ETags are sufficient, although if you use the expires module, when the browser considers requesting a cached image, it doesn't even have to send a request because it sees the timer hasn't expired yet. So using the Expires module would be easier on the server than just using ETags alone. That is all my understanding at least. With ETags alone, the browser has to send the request headers so the server can compare the If-None-Match header to the file's current ETag in order to decide
  7. Dilated

    Cacheing

    Theres several different mechanisms for client side caching. If you're using an apache server you can turn ETags for files on: http://httpd.apache.org/docs/2.0/mod/core.html#fileetagAddFileETag All to an ".htaccess" file in your root directory.Otherwise there is also the apache "Expires" module: http://httpd.apache.org/docs/2.0/mod/mod_expires.html e.g. ExpiresActive OnExpiresByType image/gif "access plus 5 hours" I can only give advice for apache because I'm not familiar with other HTTP server software.
  8. file_get_contents is unnecessary if you don't need anything from the body of the page. If the gravatar site does return a 404 for nonexistent gravatars, all you need are the headers. A GET request is unnecessary when a HEAD will do. You could use get_headers(). http://us.php.net/manual/en/function.get-headers.php $headers = get_headers('http://foo');if (!strstr($headers[0], '404')) echo('found page'); But I'm curious, why do you need to check to see if a gravatar exists? Gravatar has a fallback option for avatars, such that you can select your own image as a fallback avatar.
  9. Dilated

    favicon

    No. There's no way to do these things in css. If there is a file named, "favicon.ico" in your root directory, you don't have to put anything in the <head> of your document. However, if your icon is a different format/extension (or a different name/path of any kind), like png for example, you'll have to explicitly acknowledge your favicon with a link relation:<link rel="icon" href="favicon.png"/> An HTML document doesn't necessarily require an external stylesheet or even any styles at all.
  10. As far as I understand, it won't even strip tags that have attributes. Using a regex is more reliable.
  11. No. Do not use strip_tags. It's notorious for not working properly.
  12. Stripping all the tags is fairly simple:$str = preg_replace('/<[^>]+>/', '', $str);$excerpt = substr($str, 0, 250);
  13. You're entering into tokenizer territory if you want something this advanced. You *might* be able to accomplish this through extremely convoluted regexes, but it wouldn't be easy. You would need to be a genius with lookaheads and conditional patterns.http://htmlpurifier.org/ - This is a library that would do all the work for you to make sure everything is properly nested. As a bonus, it also removes potentially malicious code. It also ensures the markup is valid according to whatever particular doctype you select.Another possibility would be to load everything into a DOMDocument, and have DOMD
  14. Dilated

    DOCTYPE?

    I'll clarify what I was saying then. Using a doctype to trigger standards mode is definitely a practical and necessary use, but not a legitimate use of doctypes with respect to the fact that it isn't what they were intended for. If quirks mode didn't exist, we wouldn't even be using doctypes right now, because they're useless.
  15. Dilated

    DOCTYPE?

    I'm with eduardchile on this one, but for different reasons. Doctypes, in reality, serve no purpose for HTML. I'd even argue that they never served a purpose aside from triggering standards mode - which isn't a legitimate use as far as I'm concerned. But eduardchile, unfortunately, a doctype is required on an HTML page if you want it to be rendered in standards mode. I recommend just using a blank doctype: <!DOCTYPE html>. This is the doctype the html5 spec recommends, and as you see, its only there for legacy reasons.
×
×
  • Create New...