Good day to all! Once again I need the help of forum participants! The problem is this:
there are two scripts auth.php and cabinet.php, the essence of the work is extremely simple auth.php, with successful authorization, throws us into cabinet.php, but for some reason it does not work (Namely: I’ve been authorizing successfully, but I get back to the authorization page, there is a suspicion that the $ login and $ pass variables are not passed to the cabinet.php script, but why?
UPDATE:
Server on debian
On the server with FreeBSD, the same scripts work, maybe something is wrong with the php configuration?
UPDATE # 2:
Here is what he writes in the log:
[error] [client ip_adress] PHP Notice: Undefined variable: _SESSION in /var/www/cabinet.php on line 11, referer: http: //trali-val.ru/auth.php
[error] [client ip_adress] PHP Notice: Undefined variable: _SESSION in /var/www/cabinet.php on line 11, referer: http: //trali-val.ru/auth.php
[client ip_adress] PHP Notice: Undefined variable: _SESSION in /var/www/cabinet.php on line 11, referer: http: //trali-vali.ru /auth.php
[client ip_adress] PHP Notice: Undefined index: sbm_auth in /var/www/auth.php on line 11, referer: http: //trali-vali.ru/auth.php
Below is the code from both scripts.
auth.php:
\\auth.php $host='localhost'; $database='family'; $user='root'; $pswd='пароль к базе'; $dbh=mysql_connect($host,$user,$pswd) or die ("I can not be connected to MYSQL."); mysql_select_db($database) or die ("I can not be connected to base."); if($_POST['sbm_auth']) { $login=($_POST['login']); $pass=($_POST['pass']); $check_q=mysql_query("SELECT id FROM users WHERE login='". $login."' AND pass='".$pass."'"); if(mysql_num_rows($check_q) === 1) { session_start(); $_SESSION['login'] = $login; $_SESSION['pass'] = $pass; $_SESSION['usr_id'] = md5(crypt($login,$pass)); header("Location: cabinet.php"); } else { echo "incorrect login or password"; } } print("<CENTER>"); echo '<form action="" method="POST"> <table> <tr><td>LOGIN</td> <td><input type="text" name="login"></td></tr> <tr><td>PASSWORD</td> <td><input type="password" name="pass"></td></tr> <tr><td colspan=2 align=center><input type="submit" name="sbm_auth" value="ENTER"></td></tr> </table> </form>'; print("</CENTER>");
cabinet.php:
\\cabinet.php if(isset($_REQUEST[session_name()])) { session_start(); } else { header("Location: auth.php"); } if($_SESSION['usr_id'] == md5(crypt($_SESSION['login'],$_SESSION['pass']))) { echo "HELLO"; } else { header("Location: auth.php"); }
echo ini_get("session.use_cookies") . " and " . ini_get("session.use_trans_sid") . "<br><br>";
givesecho ini_get("session.use_cookies") . " and " . ini_get("session.use_trans_sid") . "<br><br>";
echo ini_get("session.use_cookies") . " and " . ini_get("session.use_trans_sid") . "<br><br>";
- Dex