Hi everyone, I am looking for someone to help me with a htaccess file / rewrite rule I am working with.
At the moment, my url is website/profile?id=12345678
now before I add the htaccess file, the webpage gets the id from the url and searches the database and retrieves the users data.
When I add the htaccess file - my url is website/user-name - Where user name is a field in my database
The webpage does not retrieve any user information as the get option is not valid.
What variable can I use to retrieve the users information.
here is the htaccess file. Hope someone can help me out on this as its driving me crazy.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /profile.php?id=$1 [NC,L]
Here is the code I have been using to retrieve the user information using profile.php?id=12345678
function validate_id($variable) {
return is_numeric($variable);
}
// Get the id from the url
if ( isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id']) ) {
// ok it is set, not empty, and a number, get it;
$id = trim($_GET['id']);
}
// use the id and search the database for user info
$results = $Db->query('SELECT * FROM table');
$Db->where('ref', $id);
$results = $Db->get('table');
if($results > 0){
//loop through result
foreach($results as $row);
Thanks in advance everyone