scott100 Posted March 5, 2006 Share Posted March 5, 2006 Only one thing I'm curious about, is it possible to use php in a way so that you still get structured html when you look at the output html code? I'm kind of a neat freak that way... <{POST_SNAPBACK}> Works like this:<html><head><?php //php code here?></head><body></body Link to comment Share on other sites More sharing options...
Jonas Posted March 5, 2006 Author Share Posted March 5, 2006 Works like this:<html><head><?php //php code here?></head><body></body<{POST_SNAPBACK}> Hmm, and what about if I use the echo statement? Do I put the spaces in front of the echo statement? Link to comment Share on other sites More sharing options...
mpoer Posted March 5, 2006 Share Posted March 5, 2006 bah, that's what I forgot: Opera testing.I'll get to work on a PHP version. That is why I usually prefer server-side scripting, it'll always work for the browser Link to comment Share on other sites More sharing options...
Jonas Posted March 5, 2006 Author Share Posted March 5, 2006 bah, that's what I forgot: Opera testing.I'll get to work on a PHP version. That is why I usually prefer server-side scripting, it'll always work for the browser <{POST_SNAPBACK}> But... I've already got a script that works now, the one choco provided. Thanks guys, but I don't need anything else I think. Only thing that would be cool is if there's a way to prevent caching so that it really is random bg for each page, not just once, but on the whole. Link to comment Share on other sites More sharing options...
Chocolate570 Posted March 5, 2006 Share Posted March 5, 2006 You can do that with cookies. If you'd really like, I can make it so that when it's got a background, it sets a cookie with it's value to the background. The next time it opens the page, it checks if the bg image it's supposed to put is not in the cookie, meaning it's different from last time. Do you want that?And my god, my php worked. I can't believe it. This really is amazing to me Link to comment Share on other sites More sharing options...
scott100 Posted March 5, 2006 Share Posted March 5, 2006 To stop caching <?php header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Pragma: no-cache'); ?> Link to comment Share on other sites More sharing options...
Jonas Posted March 5, 2006 Author Share Posted March 5, 2006 To stop caching<?php header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Pragma: no-cache'); ?> <{POST_SNAPBACK}> Does it matter where in the document I place that script? Link to comment Share on other sites More sharing options...
scott100 Posted March 5, 2006 Share Posted March 5, 2006 Yes, the header() function must be called before anything else is sent to the web browser. If your web page receives any HTML or even blank space the header() function will not work. <html><?php/* This will give an error. Note the output * above, which is before the header() call */header('Location: http://www.example.com/');?> Link to comment Share on other sites More sharing options...
calvin182 Posted March 7, 2006 Share Posted March 7, 2006 Jonas if you havent already found a resolution you can use my php code. I wont remove it no worries Just be sure that you have all of the random images in one folder with no other non-image filetypes in it. <html><head><title></title><?php$dir = "/home/DOMAIN/public_html/RANDOMIMAGESFOLDER";$domain = "http://www.DOMAIN.com";$folder = "RANDOMIMAGESFOLDER";$imgs = array();// opens image directoryif (is_dir($dir)) {if ($dh = opendir($dir)) {while (($file = readdir($dh)) !== false) {if(!is_dir($file)) {$imgs[] = $file; }}closedir($dh);}}$rand = array_rand($imgs, 1);$rand_image = $imgs[$rand];echo "<style type=\"text/css\"> body { background: url(\"".$domain."/".$folder."/".$rand_image."\"); } </style>";?></head><body></body></html> edit: heh... i guess i only read the first page, oh well. Link to comment Share on other sites More sharing options...
Jonas Posted March 8, 2006 Author Share Posted March 8, 2006 Thanks though... Link to comment Share on other sites More sharing options...
calvin182 Posted March 9, 2006 Share Posted March 9, 2006 no problem, your welcome Link to comment Share on other sites More sharing options...
bby_kougra Posted April 1, 2006 Share Posted April 1, 2006 Thanks for this! I've been meaning to find that out for a while now! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now