August 29, 201114 yr Hi there, Firstly apologies if this is in the wrong section. Here is what I would like to achieve, I want to have a login screen where you can enter a username/password and depending on the username/password entered it will direct you to a folder for that user eg; user1 would log in and be directed to domain.com/user1 user2 would log in and be directed to domain.com/user2 also obviously, user2 shouldn't be able to change the address to domain.com/user1 and be allowed access to that folder and so on. Please can anyone point me in the right direction for how to achieve this? I have been following a tutorial to create a login page but that directs to the same page for all users EDIT: maybe this should be in the PHP section here is part of the php code being used, i see where it directs to folder/index.php is it possible here to add something like; if user = user1 goto user1/index.php if user = user2 goto user2/index.php function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; header("location: folder/index.php"); } else return "Please enter a correct username and password"; } Sorry my php really isnt that great, also maybe should add the usernames / passwords are stored in a mysql db Thanks Edited August 29, 201114 yr by Jager616
October 8, 201114 yr Why don't you use username as folder names to redirect? your code will look like function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; header("location: $un/"); } else return "Please enter a correct username and password"; } To create folder upon confirmed registration use mkdir. mkdir("user_folders/$un",0777);
Create an account or sign in to comment