I've just been editing an open-source PHP application (original version at http://scripts.ringsworld.com/content-management/basiccms/ , and modifying it to suit my needs :icon_cheesygrin:
However, the PHP application is a CMS and always generates URLs this way:
http://yourwebaddresshere.com/cms/?id=1
when I am trying to get it to be
http://yourwebaddresshere.com/cms/?id=pagename
but I am struggling to try and get this to work.
This is the code for index.php that generates the pages from the database:

<?php
session_start();
include("Includes/PortalConection.php");
include("Includes/Database.php");

if (!isset($_GET['id'])) 
{
	$strID="";
}
else
{
	$strID=QuerySafeString($_GET["id"]);
}


$strDetails="";
$strError ="";
if ($strID != "")
{
	$strsql = "SELECT description ";
	$strsql .=" FROM pages_t_details ";
	$strsql .=" WHERE id=$strID";
	$conclass =new DataBase();
	$rst= $conclass->Execute ($strsql,$strError);
	if ($strError=="")
	{
		while ($line = mysql_fetch_array($rst, MYSQL_ASSOC)) 
	     {
			$strDetails=$line['description'];
		}
	}
	
}
elseif ($strID == "0") {
	$strDetails="";
}
else 
{
	$strsql = "SELECT description ";
	$strsql .=" FROM pages_t_details ";
	$strsql .=" WHERE startpage='Y'";
	$conclass =new DataBase();
	$rst= $conclass->Execute ($strsql,$strError);
	if ($strError=="")
	{
		while ($line = mysql_fetch_array($rst, MYSQL_ASSOC)) 
	     {
			$strDetails=$line['description'];
		}
	}
}
print $strDetails;
?>

I did try fixing it myself, but got errors on line numbers, so reverted it back to the default above.

You need to create a system to translate the page name (maybe like admin or home) to a number using switch. Example:

<?php
//Get Page
$page = $_GET['id']
//Translate Text to Number
switch($page)
{
   case 'home':
      $id = 1;
      break;
   case 'admin':
      $id = 2;
      break;
   default:
      $id = 0; //Invalid page message or similar to handle invalid pages
}
?>

Then simply replace all links and form actions the number id to the id's name. Ex. cms/?id=1 could become cms/?id=home and so on

This article has been dead for over six months. Start a new discussion instead.