I am storing some web pages in a MySQL database, and these are extracted and displayed when a user logs in successfully. the code below shows how the page is retrieved into a simple variable, $a, and then displayed to the screen. the name of the page is index.php.
However, the page is currently accessed as
www.myhost.com/index.php?OK=Y
but what I really want is for the PHP in index.php to generate and display a new, dynamic page with a randomly generated name, such as:
www.myhost.com/abz2345.php
and as such I don't want to store it on disk. Is this possible ?
Here is the content of index.php:
<?php
function unhtmlentities ($string)
{
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
include 'SELECT_connector.inc'; // username and password..
mysql_connect("localhost", $DBUSER,$DBPASS);
mysql_select_db("mydatabase");
$query = "SELECT * FROM webcontent WHERE CTR = '1'";
$result = mysql_query($query);
$nr = mysql_num_rows($result);
if ( $nr > 0 )
{
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$a = unhtmlentities($row['Content']);
mysql_close();
header("Content-type: text/html");
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");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo $a;
}
exit;
Does that make sense ?