I am creating a page that retireve user data from URL. http://localhost/test/index/john this is the url. My issue is I don’t want the index in my url.
example:-
http://localhost/test/john
current url:-
http://localhost/test/index/john
How can I do that? Thanks in advance
Here is the code of retrieving data
session_start();
$mylink = $_SERVER['PHP_SELF'];
$link_array = explode('/',$mylink);
$lastpart = end($link_array);
$fetch_user = rtrim($lastpart, ".php");
$path_parts = pathinfo($mylink);
if ($path_parts == "php") {
}else{
$session['user'] = $fetch_user;
$slug = $session['user'];
}
This is the code in index.php:
if ($session['user']) {
echo "<div id='slide-right'>";
include_once("user2.php");
echo "</div>";
}else{
echo "<div id='slide-left'>";
include_once("user.php");
echo "</div>";
}