|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
trouble with session variables
The problem is that I need to declare & use some session variables for logging in
this is the verify password file: just took out the ip's <?php session_start(); $connection = mysql_connect("???.???.??.???","root") or die ("Unable to connect to server."); $db = mysql_select_db("users",$connection) or die ("Unable to find Reciept database."); $sql = "SELECT password FROM users WHERE username = '$_POST[username]'"; $sql_result = mysql_query($sql, $connection) or die (mysql_error()); $row = mysql_fetch_array($sql_result); $passcheck = $row["password"]; if ($_POST['password'] != $passcheck) { header("Location: http://???.???.??.???/php"); exit(); $_session['logg'] = "no"; } else { header("Location: http://???.???.??.???/php/main.php"); exit(); $_session['logg'] = "yes"; } ?> and then this is the main.php <?php session_start(); if($_session['logg'] = "no") { header("Location: http://155.238.93.171/php"); exit(); } ?> <html> <head> <title>ICDL Prog</title> ... but now the problem is that even if you logg in correctly main still sends you back to the logg in screen, even though $_session['logg'] should be = "yes"; Any help would be appreciated |
|
#2
|
|||
|
|||
|
You need an extra equal sign in your log check. With only the single, you're actually setting $_SESSION['logg'] to 'no' instead of checking it.
|
|
#3
|
|||
|
|||
|
Quote:
I just telling u that u have some miscoding in u'r script. $connection = mysql_connect("???.???.??.???","root","password") $sql = "SELECT password FROM users WHERE username = '$_POST[username]'"; It should $_POST['username'] one more thing as per my knowledge u use relative path in header function.just mention the name of file if both are in same folder. tried it out |
|
#4
|
|||
|
|||
|
another thing you need to do is set your session variables and callsession_write_close() before calling header()
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > trouble with session variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|