H
H
Hepjin2015-06-09 07:35:23
PHP
Hepjin, 2015-06-09 07:35:23

Registration + authorization and further window for authorized users, how?

I hope there are ready-made templates? Or do you have to write everything yourself?

<?
$password = 'mypassword';
if( isset($_GET['pass']) && $_GET['pass'] == $password) {   //Проверяет пароль на правильность.

    //Устанавливает пароль в кукиес.
    setcookie("password", $password, time()+3600);

    //Можно исполозовать js redirect или header('Location:index.php?profile');
    print "Hello, Admin.   <B><a href='index.php?profile'>profile</a> <a href="?log_out">LogOut</a></B>";die; 
}

//Обработка Logout
if( isset($_GET['log_out'])) {
    setcookie("password", '', time()+3600);
}

//Если пароль не сохранен в кукиес, вывести форму для входа
if( $_COOKIE["password"] != $password) { 
?>

    <FORM METHOD=get ACTION="index.php">
        <INPUT TYPE="text" NAME="pass">
        <INPUT TYPE="submit">
    </FORM>

<?
    die();
}
?>
Here is a simple authorization code, but I don't know what to do next

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2015-06-09
@Hepjin

Horror is simple, not code.
Here is a more or less good implementation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question