Вход Регистрация
Файл: myCode/Login.php
Строк: 72
<?php

if(isset($_POST['submit']))
{
    
loginaction();
}
else
{
        
sessioncheck();
}

function 
loginaction()
{
    
    
$users = array();
    
$users['Admin'] = 'password';  // Change the username and password to something of your choice
    
    
if(array_key_exists($_POST['user'], $users))
    {
        if(
$_POST['password'] == $users[$_POST['user']])
        {
            
$_SESSION['login']['user'] = sha1(md5($_POST['user']));
            
$_SESSION['login']['password'] = sha1(md5($_POST['password']));
        }
        else
        {
            echo 
"<div id='message'>Wrong Username or Password</div>";
            
showform();
            exit();
        }
    }
    else
    {
        echo 
"<div id='message'>Wrong Username or Password</div>";
        
showform();
        exit();
    }
}

function 
sessioncheck()
{
    if(!isset(
$_SESSION['login']['user']) || !isset($_SESSION['login']['password']))
    {
        
showform();
        exit();
    }
}

function 
showform()
{
?>
        <html>
        <head>
        
        <title>myCode</title>
        
            <style type="text/css">

            body {
                font-family: Helvetica;
                font-size: 12px;
                color: #555;
                background: #eee;
            }

            form {
                width: 440px;
                margin: 10% auto;
            }

            input[type="text"]{
                font-size: 14px;
                color: #555;
                width: 220px;
                height: 34px;
                padding: 4px;
                border: 1px solid #ccc; 
                border-top-left-radius: 5px;
                border-bottom-left-radius: 5px;
                float: left;
                margin-bottom: 7px;
            }

             input[type="text"]:focus{
                outline: none;
                background: #fff;
                border-color: #9abb70;
            }
            
            input[type="password"]{
                font-size: 14px;
                color: #555;
                width: 220px;
                height: 34px;
                padding: 4px;                
                border: 1px solid #ccc;
                border-left: none;  
                border-top-right-radius: 5px;
                border-bottom-right-radius: 5px;
                margin-bottom: 7px;
            }

             input[type="password"]:focus{
                outline: none;
                background: #fff;
                border-color: #9abb70;
            }
            
            input[type="Submit"] {
                  font-weight: bold;
                  color: #fff;
                  background: #9abb70;
                  padding: 5px 25px;
                  border: none;
                  border-radius: 3px;
                  float: right;
                  -webkit-transition: background .1s ease-out;
            }

            input[type="Submit"]:hover {
                  background: #aac785;
            }            

            #message {
                  color: #dc4545;
                  text-align: center;
                }

            </style>
            </head>
        <body>

        <form method="post" action="">
        
        <input type="text" name="user" placeholder="Username" />
        <input type="password" name="password" placeholder="Password" />
        <br />
        <input type="submit" name="submit" value="Login" />
        </form>
        
        </div>

    </body>
    </html>
<?php
}
?>
Онлайн: 1
Реклама