There is a USERS table in MYSQL, where each user has his own ID. It is necessary to make it so that when the user enters his office, the URL contains the string http://suite/$id , where $ ID = user id. I can not figure out how to implement ...

  • .htaccess to help you :) - atnartur

2 answers 2

You need to read about CNC (Friendly URL) and mod_rewrite in general in order to understand the essence, as well as see examples of implementation .

If it is very figurative and schematic, then the links you can have are: http://mysite.ru/user_profile/user_id/100500 and appear in this form in the address bar of the user. With the help of pre-written rules, these links are converted to a more familiar look: http://mysite.ru/user_profile.php?user_id=100500 and process requests, as in the usual formation of links

    In this spirit:

     login.php <? $login = $_POST['login']; $pass = $_POST['pass']; $res = $db->query("select * from users where login=$login and pass=$pass"); $res = $db->fetchAssoc($res); if (intval($res['id'])>0) ``{define('USER_LOGGED',TRUE);header('Location: http://example.com/user/'.$res['id'].'');} else echo "Error"; ?>