Hi,
I have been trying for the last few days to figure out how to send a particular user to their own specific URL. For example, all users will use the same login.php page but when User A logs in they will be redirected to A.php and if User B logs in they will be redirected to B.php.
I am totally new to php and have been using it for about 3 weeks. I am very familiar with html. So far I have managed to create a script where a user can log in and they will be redirected to logged-in.php regardless of who logs in.
This is the code in which I am having problems:
<?php
require 'config.php';
$login = $_POST['login'];
$password = sha1($_POST['password']);
$db->query("
SELECT COUNT(id) AS total,
login
FROM users
WHERE login = '$login'
AND password = '$password'
");
$result = $db->get();
if ($result[0]['total'] == 1)
{
$_SESSION['userLogin'] = $result[0]['login'];
$_SESSION['isLogged'] = 1;
header("location: " . $row['id'] . ".php");
exit;
}
else
{
header('location: index.html');
exit;
}
I am trying to redirect a user to their particular id and then index.php. For example User A's id (created in phpmyadmin) is 12345 - So what they should be redirected to is 12345/index.php. What is currently happening with this is users are simply getting redirected to http://mydomain/.php
I feel as though I should be adding a mysql_num_rows somewhere but have no idea where to put that script. Any help would be greatly appreciated. If required I can add my currently working php script which allows users to log in to logged-in.php and allows them to successfully log out.
Kind regards,
Robert.