Caching Pages With Php
In this post I will try to give a view of what is the custom caching with php, why and how we can use it.In the modern days, most of the sites are database driven. That means that your site is actually an application which retrieves data from a DBMS ( database managment system, eg MySQL) , parses the data and shows the result to the user. Most of these data are usually don't change frequently or don't change at all, and the reason that we use the database is that we can easilly update the site and the content.A problem that this process creates is the server overhead. Every time we execute a query in the database, the instance of our script will call the DBMS, and then the DBMS will send the results of the query. This is time consuming, and especcially for sites with heavy traffic is a real big problem.How we can solve this problem?There are two ways to solve this if you want to make your site faster. First is optimizing the quesries, but we will not talk about this at the present article. The second and most valuable is using some kind of custom caching technique. Custom caching with phpFirst let me explain the idea behind custom caching. When we have dynamic pages that their data is not updated frequently, we can use a 'system' that will be able to create the page, and then store it for later use. That means that after the page's creation, our application will not run the queries again in order to display the page, but it will show the cached one. Of course this system must be able to keep the cached pages for a time period that we will set.Let's code itHere is a simple class that will do the job. Let's see the code first:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Caching Php Pages?
HOW to make my pages freshly loaded by default. this is a problem when pages get cached that query databases because when you go there you get the cached page as opposed to the page updated with the database's info. how do you get pages to automatically load themselves from the server, not the cache?
Caching Dynamic Pages Dependant On User Status
I am new to caching dynamic pages. All I knew was how to avoid caching. My dynamic pages have on top of them an html header which shows the status of the user logged/not logged. I would like to cache the pages and force re-cache if there is a change in the user's status. I guess the must-revalidate has to be always present. I use a last modified date which comes form my database. I think Cache-Control: must-revalidate depends on the last modified date... am I right? Should I change that modified date to the time the user logs off or on? Is it ethical checking the user agent for bots? When dealing with bots should use the real last modified date.
Avioding Expired Pages, & Carrying Data Accross Multiple Form Pages
I have a checkout/order form that consists of 6 pages, all PHP. The are linked to one another, like, after the user finishes page 1, they proceed to page 2, etc... The first two pages are submitted by a GET link, so those are not in my question. The next 4 are submitted using a <form>. Throughout all of the pages, i would probably have about 25-30 variables, things that the user has to fill out. I have two questions, 1. What would be the best way for me to keep track of all the data moving throughout the pages, like storing it from page 4, and i still need to access it on page 6. 2. I don't know if anyone could help me here, but does anyone know of a way to code around those ugly "page expired" pages, because of a submitted form. If a user needs to go back, which most likely they will, is there some sort of way for me to skip the expired page?
Converting Html Pages Into Dynamic Pages
I built a website in html, using Dreamweaver. I need to have a database built within these pages and the person who is going to do it told me that they will have to convert all my html pages into dynamic pages (php). Is it complicated to do this or do I just have to save my pages in php instead of html in Dreamweaver ?
Caching
I am currently writing a PHP program and I am just wondering what Caching does.
Caching
I need to implement a caching mechanism for my script URLs. Instead of www.domain.com/script.cgi?id=1234 , which the browser will obviously not cache, I want the URL to be something like www.domain.com/1234 or www.domain.com/1234.htm instead. This way the browser will cache the page. I have two concerns: 1) Is this possible without rewriting the url? If so how? 2) The result page will be different for different users. Will this cause trouble with proxy servers? My goal is only to cache a particular version for a particular user so that if he requests the URL again (within X minutes) the server doesn't have to process it again.
Caching
I want to make it so that browsers will cache the images, scripts and css pages from my site, but not the php pages themselves. Is all I need to do add this? header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache');
Caching Images
Is there a way to set different levels for different content? I have been looking at different sites with cache tuts and docs and many seem to imply this can be done how fail to mention how. Each one states the syntax for producing http headers for the document being requested which is straight forward enough, but what about the objects within the document? I would like to cache images for a relatively long period of time but allow dynamic content (php) to be updated very frequently. Anybody have any input/links?
Caching Problem
I have a problem with caching. Basically I have input forms where people add content but it seems to retain the pages in the cache so when they go back to edit them, they get the old cached version which does not reflect their changes. To see the changes you have to force a refresh using CTRL + F5.I've got this at the top of my code file but it doesn't seem to help: header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache");
Caching Problem With GET
When I insert into my code a redirect to the current page, e.g. <A HREF="news.php?item=4">News</A> It doesn't work and seems to bring back pages that have been cached by my server (I'm hosted by an ISP) and processes the code as if a different value has been passed in. If I change it to: <A HREF="news?item=4">News</A> i.e. remove the extension, then all seems to work fine, but all the sites I've been to include the extension.
Sessions And Caching
I've constructed a series of 5 forms for the user to fill in, at the end of the series, there's a final page which displays the input, and allows the user to go back and edit each form. Each form has 4 "modes". They are: 1 (One)- User input of info into blank page 2 (Two)- Validation/handling of the above input 3 (Three)- User editing existing info 4 (Four)- Validation/handling of the above The final form (the one which reviews the input) sets $_SESSION['edit'] to true. Quite straightforward eh? So if any of the 5 pages is accessed and ($_SESSION['edit']) then I've made the script go to mode 3: PHP Code:
PHP & RSS -- Caching Requests
To start, I'm pretty experienced with a lot of aspects of PHP but I've never gotten into caching. On a lot of sites there's a request of how often you grab an RSS feed. For instance, on Del.icio.us there's this message: "Please do not poll any single RSS feed more often than every 30 minutes. RSS feeds are not updated more than twice an hour, and you will receive an error if you try to crawl more frequently." What's the best way to pull RSS feeds and still abide by sites like del.icio.us' terms/requests?
Caching IP For Hit Counter?
what's the easiest way to cache an IP for use in a page hit counter, so that if the viewer clicks 'refresh' the counter won't increase; ie it'll only increase when unique viewers access it.
Caching Jpg Files
A question about caching jpg files, I have pages where dozen of jpgs are displayed at once. Those jpgs come from resizing jpgs, so this is a costly way for server (computing jpgs and send them to client). So is there any way to cache resized jpg to avoid them being resent every times ?
Sessions And Caching
I'm trying to work with sessions for a moment and noticed that session's usage triggers cache control method and pragma switching to no-cache. I've read that session.cache_limiter parameter can be used to specify the type of caching (none/nocache/private/private_no_expire/public). Is no-cache method really needed by session mechanism? If no, what caching type is better for SE?
Session Caching
I submit a value in a form on go to the next page, where I fill in another value and post that to the next page, then I hit the browser back button to change 1 of the values and resubmit but the problem is that it is not updating the overwritten value?? Is this a session problem or my browser?? ANd is there a way I can solve this???
Browser Caching ?
Let's say I have a page that is primarily HTML but I added a few small parts that are PHP, for example a random banner. The page is in no way PHP driven, it just has some some random stuff like the banner and/or a tip of the day. What bothers me is that the PHP page won't be cached, so if the page has a lot of links and, on average, the user clicks ten links (hitting the back button after he does that) my bandwidth usage increases tenfold. I think I can send cache headers but I don't know much about them. Is it possible to set it for, say, an hour so that if he hits the back button he'll get the same banner/tip of the day that he originally got (because he's looking at his cached page) and only after an hour will he get a new random banner/tip ?
PHP Caching Classes
I'm getting a really odd behavior with php. It is caching my classes. I have a very simple file: <?php class testclass{ } ?> The first time I run the page it works correctly and creates the class. If I run it again it simply does this: Fatal error: Cannot redeclare class testclass in C:Inetpubdefaultindex.php on line 2 It doesn't matter what class name I use. The first time it executes it saves the class for future requests. My setup is IIS 6 on Windows Server 2003 PHP 5.2.1 installed as an ISAPI extension. If I restart IIS it seems to clear this cache and executes correctly the first time. But then it stays cached. *note This also occurs with define such as: define('test', true); executes the first time, states it is already defined the second. Anyone have any idea what would be causing this to happen? I've never seen this situation before.
Apache 2.0.45 + PHP 4.3.1 Caching Problem
I had some hardware problems with my old machine so I had enough reason to set up a new one : Gentoo 1.4 + Apache 2.0.45 + PHP 4.3.1 + MySQL etc. I took the applications from the old server and put them onto the new machine. So far so good. After a while I saw some *really* strange behaviour : What ever I did, IE cached every dynamically created page. I thought I could remedy the problem by adding some meta pragma HTTP heads into the html templates. Didn´t work. I added hardcoded Header Flags directly into the php code. Didn´t work. On the old machine everything works fine. IE just shows the *current* db generated content once you press ctrl + F5. Neither just pressing F5 nor hitting the link to the page again shows the current content. That is really bad if you´re running a message board or something with changing data per minute Is there anything new to apache or php I am not aware of ?
Caching Php Files Difficulty
I need to execute a php file with mysql requests on the server without the file being sent to the client. I'd rather have the result of the execution of the php file being written in a plain html file on the server. I've tried turning output buffering on, but unable to get content.
Secure Login Caching?
I am using the following session functions at the top of each protected page: session_cache_limiter('private'); session_start(); the problem I am having, is i find if the customer just clicks refresh, it will not update the info on the page from the database. I have to actually hold crtl and click refresh to do a complete reload of the page. Is there anyway around this? What is the best way to cache "secure" pages?
How To Stop ODBC Caching On IIS
I've got a small test program that reads a remote file using ODBC with a local system DSN :- <?php session_cache_limiter('nocache'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> <html> <meta http-equiv="refresh" content="10"> <?php if (!$link_id = odbc_connect ('secpay','','')) die("Failed to connect to RMS database"); //Links to database var_dump(odbc_error($link_id)); var_dump(odbc_errormsg($link_id)); echo "connected to secpay!!"; $sql = "SELECT * from dist_write:secpay;"; $exec = odbc_exec($link_id, $sql); var_dump(odbc_error($link_id)); var_dump(odbc_errormsg($link_id)); var_dump($exec); odbc_result_all($exec); ?> The program reads the rows without a problem, but if I delete the source file, the script continues to return the rows and doesn't show any errors. I believe this to be an issue around IIS. If I execute 'IISRESET' to restart the service, the script starts to return 'No Rows' instead. Does anyone know how I can force IIS to stop caching this query/PHP script, and always read the file?
Caching PHP GD Dynamic Images
I have a PHP script that takes a handful of parameters and outputs a graphic based on those parameters. The file name is a direct representation of the input parameters. For example (widgetized): image.php?a=red&b=big&c=png outputs the file red.big.png to the web accessible directory /output/ I've actually already picked a way of caching the output of this script but would like to discuss possible alternatives and get a feel for "best practices" in this area. Here are the two general methods of caching I had originally considered: Method A) The PHP script is called through an <img /> tag and first uses the file_exists() function to see if the image has already been made. If it does exist, the PHP script uses the header() function and the readfile() function to output that existing image. Or if it does not exist, it generates the image, writes it to the static position then uses header() and readfile() to output the image. Method B) The images are called using the static path in an <img /> tag. The directory /output/ uses a custom 404 error page (image.php) which parses out the $_SERVER['REQUEST_URI'] with the explode() function to populate the input parameters and generate the image. It puts the image in the static folder, then uses header() and readfile() to output the image to the server. 1. What are the pro's and cons to these two different methods of caching the images? 2. Is there any reason why either method *can't* be used? 3. What other methods are there? Or, how would you improve on these methods? I'd appreciate your input on this subject, or if you can recommend other Apache directives/PHP functions that would be useful in this scenario.
Page Keeps Caching Old Data, How To Fix?
i have a php page that has a series of check boxes in it and you press the update button after unticking some boxes and ticking others. after the page updates the changes actually take place in the database but the page displays the old state where it was before you ticked and unticked the boxes. as soon as you press Ctrl + F5 it actually updates the page to what is in the database. how can i fix this so when i press the update button it refreshes and doesnt cache the old state? i have the following in the header but it dont seem to work, is there anything else i need to do? <meta http-equiv="pragma" content="no-cache"> <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
Caching A Part Of A Page?
I am working on a custom banner generator for some of our users. Its basically a flash banner that can take vars for colors etc, so users can integrate with their sites colour scheme. Its set up currently with the banner at the top as a preview, with e.g. .swf?color1=00000&color2=45efef in the object and embed tags. Below this is a script that is 3 nested for loops, that increment a var each and convert that to hexidecimal. The three hex refs are then concat'd together, and set as a CSS background to a transparent gif with an href around that calls the same page with the new colors in the url, which get passed back to the flash movie. (hope im making sense here :)) So theres about 500 or so (im incrementing the vars by two,otherwise its way sloooow) <a><img></a> that have to be generated on each page load. Im wondering how and if i can speed this up?
Smarty Caching Logic
How long does a $smarty->clear_cache(..., ...) function take? More specifically, how long would it take to run 300 or more of them? I'm implementing Smarty's caching in my application, and when a user lists himself in three hundred cities, I need to clear the cache for those 300 city pages. So should I run a loop that clears the cache for all those city pages, or should I let the cached pages expire every five or ten minutes? Or is there some way I can take advantage of cache groups (the a¦b¦c thing as described in the manual)? Maybe there's some way I can pass an array of $compile_id's to clear_cache()...
Image Caching In Firefox
I have been trying to create a slideshow of random pictures on my website. It has been quite succesful (it works perfectly in IE) but Firefox refuses to cooperate... It seems to have something to do with the way Firefox caches pictures, but I'm not sure. There is a html file, which puts rotate.php as a picture on the page. There is a javascript file, which puts a new rotate.php in the image frame every four seconds. There is a PHP file, rotate.php, which randomly outputs a picture. I'm not sure I'm posting this on the right forum, since PHP, HTTP headers and javascript are involved and I don't know what part is causing the problem. I'll post a part of rotate.php below.. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 thumb($filename, 170, 170); // thumb is a working thumbnailgenerator, it outputs correctly in both browsers)
Preventing Image Caching?
I have a script that dynamically draws images, and I output the image to the screen like this: <p><img src="image1.jpg alt="bar graph" /></p> My script changes image1.jpg everytime it is executed, but the browser is caching the first occurence of image1.jpg, so I am not getting the new image1.jpg to display. I know that the image is being redrawn because I can go check image1.jpg in my directory, and see that it is updating, but my script does not reload the latest version. Any suggestions?
Caching+file Locking
I've configured apache to fetch filename.htm if user requests filename.htm. But if filename.htm does not exist, apache will call index.php. Now, index.php will generate a page, buffer it using ob_start and then save it as filename.htm (thus, effectively filename.htm is cached as static file on server hard disk) Every 10 minutes a cron job deletes filename.htm So all users requesting filename.htm would be served with the static version if it exists, otherwise a latest dynamic version created by index.php. Any comments about using this type of caching technique..? Any concurrent read/write problems that anyone foresees?
PHP Image Generation & Caching
My basic problem is with a page (HTML) which is intended to display an image slideshow. On this page there are a number of links to click (one for each slideshow topic) and a "TV screen" to view the results. The images are stored on the server as (big) JPG files - and when they are downloaded for the slideshow, I resize them with a PHP script "im.php" : $filename = $_GET['filename']; header('Content-type: image/jpeg'); .. ..... open $filename & do the resizing .. imagejpeg( ... After a link is selected, I preload the set of images with Javascript by doing : im[i].src = "php/im.php?filename=" + getFName(i); // for each in the set where getFname(i) returns the i'th image in the set. I then start the slideshow (I've got things in the Javascript to make sure all images are preloaded before starting) Now, my problem is that the browser doesn't seem to be caching the images and keeps making server requests during the slidehow (which rather defeats the idea of pre-loading) If I "cheat" and replace the preloading with : im[i] = getFName(i); it works fine (i.e I can switch the server off & it continues to show the slideshow). This happens with all browsers I've tried (IE6, Firefox, Netscape)
Content Management And Caching
I use PEAR Cache to cache the frontend pages of a content managed web site. Now I update the contents of a page, and of course the updated contents will only be displayed after the expiring period of the cached file. After thinking and googling a lot I see several possible approaches to for handling this, each of which has it's downsides: - Use a very short expiring period. (Downside: Makes caching only relevant at very high visitor frequencies.) - Change database, add modification date to every record - and compare creation date of cache files with modification dates of contents. (Huge overhead; must first detect which tables and records the page uses at all.) - Flush cache everytime an admin page is called, or within the insert, update, publish etc functions. (Empties whole cache also if only a comma is changed.) - Provide an "flush cache" button for the administrator to use after finishing changes. (Administrator will forget it.)
PHP Caching Output Of A CGI Script
I am calling a script using php's virtual() function, which works in the same way as adding <!--include virtual="".. to a page. This works nicely and my site is working well. I'm looking for a way to speed up some of the index pages, which call a script several times. I've tried caching the output using cache_lite, cgi_cache and several other hotscripts scripts, but each has the same problem. They all cache the page up to the point where virtual() is called, then stop. Until the cache timer runs out, only the top fragment of the page is displayed. The full page then displays, but only once, and if the page is refreshed, only the top fragment again. Has anyone seen this problem and know of a reliable way to cache pages that are called in this way?
How Do I Make My Page Stop Caching?
I have a PHP page that holds info that comes from a MySQL database. I have another page that modifies the info to the users liking, and then sends them back to th first ppage with all the info. Problem is it shows up the same as before. For example, if I delete one of the entries, it's still there when I get sent back.
Random Numbers And File Caching
I have a problem with a flash file I have. The content of the flash file comes from a database and it is just text. The problem I have is that if a user visits the page and then revisits the page within a reasonably short period of time, they will see the flash file wih the old content. This is down to the SWF being cached. I have tried several workarounds to eliminate this and have had limited success. Here is an idea I had for a solution, I just need help wih how to do it. I want the path to the SWf to point to a PHP file which will return filename.swf?(random number) ie: filename.swf?243467 This will be different every time a user visits and as such, the swf should not be cached. What code would I use to achieve this? NOTE: I cant have any PHP in the URL as it is being used on third party sites that dont use PHP.
Preventing Browser-caching Between Frames
my web-application uses two frames, one with a list of database records, one with a record detail view. From the detail view there is "mark" function that will mark the respective record in the list frame (with a special color). Now this mark function is meant to toggle the mark status in the list frame, i.e. switch it on with the first click and off with the second. Problem is, the marking works, but the second click will not have any effect. Only when I click on another link in the list frame and _then_ click "mark" again will the marking be switched off. I assume this is due to the browser caching the request, and when it gets two times the same request (i.e. "list_records.php?marknode=42"), just ignores the second one. All no-cache parameters are already set in the headers, like: header("Cache-Control: no-store, no-cache, must-revalidate"); (as described in the PHP manual), but this doesn't seem to work. Or maybe the described behaviour is based on something else?
Pre-caching Common Queries On A Database
In trying to improve the performance of searches on a database, I read that it makes sense to run a small set of common queries off-line and cache them in a plain HTML file, and then use HTTP Location: to point to the static page. Problem is the book I read only talks about CGI. Can anyhow tell me/point me in the right direction for doing a similar thing using PHP?
Page Caching, MVCC, Postgresql
I had a problem today where I had an editor page (edit2.php) that posted data to PostgreSQL, and then a view page (view.php) that read it in and displayed it. At first I thought this was an MVCC issue in PostgreSQL because it was not displaying the latest changes, but the second-to-latest changes. The end user was using IE 5, so he saw the problem, but I was using Mozilla in RH9 Linux, so I never saw the problem. Turns out it had nothing to do with MVCC feature in PostgreSQL. I resolved the problem by adding this in my banner.php that loads with a require() at the top of my HTML in order to display a banner on each page. if ($nocache_page) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); } and on pages where I needed to ensure no cache was used, I implemented this feature by simply putting $nocache_page = TRUE; in it before banner.php was called. By using the condition check, it permits me to have some pages to cache and other pages to not.
MySQL Caching / PHP Input Suggestion
I'm making a Search Suggestor that every time someone searches something, it adds it to a database. If its already in there, it increments the value by 1. I'm building it in Flash using AMFPHP to connect to the database so its normal PHP Queries and results etc.. How should I go about handling the database queries if there were say 5,000+ people using it at once? I'm going to have it query per second rather than per keystroke (only if the input has changed from one second to the next so its not querying the same thing over and over).
Image Caching In Internet Explorer
i have a imageupload script which resizes the image to a thumbnail and adds infomation to a database, if some one wants to change the image they upload the new one and it overwrites the old one, problem is that the old image that was there is still stored in the cache and is displayed on the page still until you click refresh on the toolbar. This only happens in internet explorer though and firefox it works fine.
Caching Images On The Clients Machine
I am using and image viewer plugin to view tif files via a web browser. It can only use paths like "C:image est.tif" to view the files.... the problem that i have is that i need to download the images on to the client machine when a request is made for viewing that image and the client can view the image via the browser.... please note i tried using other paths such as http://test.com/image/test.tif ..... it doesnt use the http protocol please note i cant use any other plugin hence i need to find out how i can cache images locally...... basically what i want to do is when a request is made for an image i download it to the client and set the path for the viewer to the local machine and then when the viewer is loaded on the browser it can use the local image for viewing?
Problem With File_exists Caching Even When Clearstatcache() Is Called
I've created this little function to check whether a user has uploaded a file with the same name as an existing file, and if so rename it to file-1.jpg, file-2.jpg etc. clearstatcache(); if(file_exists("$BasePath/$FileName.jpg")){ $extra=1; while(file_exists("$BasePath/$FileName-$extra.jpg")){ $extra++; } $FileName="$FileName-$extra"; } However if files are deleted outside PHP file_exists still returns true so it keeps adding higher numbers to the files. Is there any way I can get round this? The strange thing is if I call file_exists() on a folder it works fine.
Caching MySQL Search Query & Results
I'm developing a site that may eventually have a very large database of users (hopefully, but who knows). It will be a community website where users can search each other (think Friendster, Classmates, every dating site out there, etc.). Often there will be queries with multiple joins and sometimes may include a few fulltext searches. Each page of results will have a limited number of results displayed (obviously). As I understand it, MySQL caches only exact queries, so doing a LIMIT (x,y) on each query to get results for the specific page will cause MySQL to run the entire query again, instead of pulling from the cache. I will limit the results to 1000, but what's the best way to limit results per page? I was thinking that I could run the SELECT and LIMIT to 1000, then do a mysql_data_seek to jump to the starting row for the page and fetch a certain number of rows for the page. For each page, the exact same SELECT would be used and therefore the results would be cached. Also, how should I save the search query? The users will be searching with any number of search terms, way too many to do use GET variables. I don't want to create a hidden form with each search term as hidden inputs (for one, that's kind of lame). I was thinking of saving the search query to the database, I guess I could implode the POST array into a string and then save it in the db.
Load Balance Servers And Caching Systems
1.) I'm using PHP and MySQL for an information heavy website 2.) We're on a load balancing system with something like 7 servers 3.) Seperate MySQL server 4.) It is sometimes the case that information has to be updated IMMEDIATELY So, my question is, how do you add caching of database pages to this mess? Here is what I have come up with so far: You have two databases, one with the page information (lots of it, we'll say) and one with just an id and a timestamp (for when stuff was last edited in the other db). When a page is called one of three things will happen; 1.) The page has not been created so a call is made to the DB, the page is made then it is served 2.) The page has been created and there is no new info in the database so the page is served 3.) The page has been created but there has been an update to the database so a database call is made and the old page is replaced and then serverd. My question is, will this be effective ince we get a lot of hits to database call heavy pages? If not (or if so) is there a better way to do this considering the top four points?
Sending People To Specific Pages That Are Coming From Specific Pages...
I want to show some specific pages to people that comes to my site from specific urls, I know the variable $_SERVER['HTTP_REFERER'] will be used but how? For ex if the visitor comes from a site that is like: I want to send this person a specific.php . I used below code but not worked: <?php if($_SERVER['HTTP_REFERER'] == "www.cominghost.com" || $_SERVER['HTTP_REFERER'] == "cominghost.com" || $_SERVER['HTTP_REFERER'] == "www2.cominghost.com"){ // Specific page html goes here } else { header("Location: index.php"); } ?> This code not worked for some cases like if the visitor comes from http://www.cominghost.com/account/targeturl.php or http://cominghost.com/account/targeturl.php Ok I know the if statement not working but How?
On The Fly Php Pages
what coding you would use to create pages based off 1 template. For example http://www.mysite.com/index.php?page=1 http://www.mysite.com/index.php?page=2 http://www.mysite.com/index.php?page=3 So that I can edit changes to all my pages just be editing index.php. I don't have access to a sql database so I have tried different ways of using the echo command but no luck. Does anyone know how to do this?
Utf-8 Pages And Php 4.1.1
I'm running into a problem with php 4.1.1 on IIS (XP Pro version). For example writing a page test.php that starts with <?php session_start(); ?> <?php echo '<?xml version="1.0"' ?> <?php echo ' encoding="utf-8" ?>' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><!-- InstanceBegin template="/Templates/stdPage.dwt" codeOutsideHTMLIsLocked="true" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> .... and saving the test.php in UTF-8 format in UltraEdit-32 or SciTE, then running the page, there's a complaint for session_start() about headers/page data having already been sent. If the same page is saved as "plain" ASCII, it works. Any ideas how to get an UTF-8 encoded page to work in php 4.1.1, without upgrading?
Web Pages
i am trying to make a homepage in PHP but something along the same lines as the frames that you can use in HTML, so it allows you to have the different frames for opening different pages, but i was wondering how i would do that within PHP.
|