Web Design Forum: Redirect by username - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Redirect by username Secure Access

#1 User is offline   Jager616 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 29-May 11
  • Reputation: 0
  • Gender:Male
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 29 August 2011 - 06:00 PM

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

This post has been edited by Jager616: 29 August 2011 - 07:49 PM

0

#2 User is offline   maslan 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 01-October 11
  • Reputation: 0
  • Gender:Male
  • Experience:Nothing
  • Area of Expertise:Designer

Posted 08 October 2011 - 05:46 PM

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);

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users