Skip to content

Instantly share code, notes, and snippets.

@ARMADAIX ARMADAIX/admin
Created Mar 11, 2018

Embed
What would you like to do?
<?php
// старт сессии
session_start();
// если были отправлены данные
if(!empty($_POST)){
// Сравниваем введенную капчу с тем, что храниться в сессии
if($_SESSION['capcha'] == $_POST['capcha']){
echo 'Капча верная';
}else {
echo 'Капча не верная';
}
// Удаляем значение капчи из сессии
unset($_SESSION['capcha']);
}
?>
<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
$mesaj = '<div class="message info">Connect to Admin Panel</div>';
if(isset($_POST['logare'])) {
$name = $db->EscapeString($_POST['login']);
$pass = $db->EscapeString($_POST['pass']);
$sql = $db->Query("SELECT id FROM `admins` WHERE `login`='".$name."' AND `pass`=MD5('".$pass."')");
$num = $db->GetNumRows($sql);
if($num > 0) {
$db->Query("UPDATE `admins` SET `online`=NOW() WHERE `login`='".$name."'");
$_SESSION['EX_admin'] = $name;
redirect('index.php');
}else{
$mesaj = '<div class="message error">Wrong Username or Password</div>';
}
}
?>
<body class="login">
<div class="login-box widget">
<header><h2>Admin Login</h2></header>
<section>
<?=$mesaj?>
<form id="form" method="post">
<p>
<input type="text" id="login" class="full" value="" name="login" required="required" placeholder="Username" />
</p>
<p>
<input type="password" id="password" class="full" value="" name="pass" required="required" placeholder="Password" />
</p>
<p class="clearfix">
<img src="capcha.php" width="120" height="40" /><br />
Digits in image: <input type="text" name="capcha" /><br />
<button class="button button-gray fr" type="submit" name="logare">Login</button>
</p>
</form>
<ul><li><a href="#">Forgot password?</a></li></ul>
</section>
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.