Redirect user according to login name [closed]

-3

I'm trying to put a login system where anyone accessing your login will have access to a different page. I am using php and mysql, but I am very new to the subject. I wanted the system to work like this:

login: lucas password: lucas

The person would be referred to a specific page

login: daniel password: daniel

Person would be routed to another page

Well, I must have left the question a bit unpleasant and that's why I came here to complete it:

I tried to create a system of registration and a login, where the login will send you to a page that in this case will be "www.site.com.br/usuario"

the status codes in the folder below:

link

    
asked by anonymous 09.01.2016 / 11:30

3 answers

1

There is no published code I will say a generic:

<?

if($lucas){
header('location: https://example.com/lucas');
}

if($daniel){
header('location: https://example.com/daniel');
}

?>

Notes:

You can also do the following for all users:

header('location: https://example.com/'.$nome); 
//terá o mesmo resultado neste caso

Note:

If you use editors like Dreamweaver you need to turn off BOM when saving the file, this can be done in Unicode Options and uncheck, when it will save, otherwise a result will be sent before redirecting which may cause error. In addition, obviously not having spaces before <?php or any other echo before header.

    
09.01.2016 / 18:09
1

No .htaccess enter this data:

AuthType Basic
AuthName "Dados"
AuthUserFile /home/host/public_html/<DIRETORIO>/.htpasswd
Require valid-user

Now in .htpasswd just go to link to generate a login and password, which we will use as an example this:

administrador:$apr1$5tnojPc/$QVe0Hkbg4ymK8NJHdkCDk0

Login: administrator Password: senhateste

:)

    
10.01.2016 / 06:44
0

If you want a way to access directories by entering a login and password without requiring the use of a database and a login / registration page, I believe that with .htpasswd work.

    
09.01.2016 / 22:41