How to implement the function? I know that I need to keep the session in the cookies, but I do not know which ones? Or tell me some article with a simple example (I searched but found nothing good on the Internet).
index.html
<div align="center"> <form name="form" action="home.php" method="post" class="form"> <label>Логин</label> <br> <input class="inputlp" type="text" name="login" value="admin" > <br><br> <label>Пароль</label> <br> <input class="inputlp" type="password" name="pass" value="123456" > <br> <input type="submit" id="submit" class="input_button-" value="Войти"> </form> </div>
home.php
session_start(); $login = trim($_POST['login']); $pass = trim($_POST['pass']); require_once ("./config/admin_config.php"); if(isset($login) && isset($pass)){ $res = profile($login,$pass); if($res == 1){ $_SESSION['register'] = $login; $register = $_SESSION['register']; } } ?> <?php if($_SESSION['register']){ require_once ("./html/home_page.php"); } else { include("./error/error.php"); }
Check function in the database login and password:
function profile($login,$pass) { $sql = mysql_query("SELECT * FROM `admin_profile` WHERE `login`='$login' AND `pass`=md5('$pass')"); $res = mysql_num_rows($sql); return $res; }