Skip to content

Instantly share code, notes, and snippets.

Created Mar 11, 2018
What would you like to do?
// старт сессии
// если были отправлены данные
// Сравниваем введенную капчу с тем, что храниться в сессии
if($_SESSION['capcha'] == $_POST['capcha']){
echo 'Капча верная';
}else {
echo 'Капча не верная';
// Удаляем значение капчи из сессии
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;
$mesaj = '<div class="message error">Wrong Username or Password</div>';
<body class="login">
<div class="login-box widget">
<header><h2>Admin Login</h2></header>
<form id="form" method="post">
<input type="text" id="login" class="full" value="" name="login" required="required" placeholder="Username" />
<input type="password" id="password" class="full" value="" name="pass" required="required" placeholder="Password" />
<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>
<ul><li><a href="#">Forgot password?</a></li></ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment