Note that there are some explanatory texts on larger screens.

plurals
  1. PO$_SESSION equals value from database?
    primarykey
    data
    text
    <p>when a person logs into my site i need to check a value in a database for their roleid, and dependent on that i need to allow/deny access to a page.</p> <p>I have this code but it says that the $_SESION variable 'Access' is undefined, i cant see why?</p> <pre><code> $email = mysql_real_escape_string($_POST['email']); $password = md5(mysql_real_escape_string($_POST['password'])); $checklogin = mysql_query("SELECT * FROM person WHERE email = '" . $email . "' AND password2 = '" . $password . "'"); if (mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $roleid = $row['roleid']; $_SESSION['Email'] = $email; $_SESSION['LoggedIn'] = 1; $_SESSION['Access'] = $roleid; echo "&lt;h1&gt;Success&lt;/h1&gt;"; echo "&lt;p&gt;We are now redirecting you to the member area.&lt;/p&gt;"; echo "&lt;meta http-equiv='refresh' content='2;index.php' /&gt;"; } else { echo "&lt;h1&gt;Error&lt;/h1&gt;"; echo "&lt;p&gt;Sorry, your account could not be found. Please &lt;a href=\"index.php\"&gt;click here to try again&lt;/a&gt;.&lt;/p&gt;"; } } </code></pre> <p>This is the if statement that is saying the session in undefined:</p> <pre><code>if (!empty($_SESSION['LoggedIn']) &amp;&amp; !empty($_SESSION['Email']) &amp;&amp; $_SESSION['Access'] == '2') </code></pre> <p><em><strong>EDIT</em></strong> Sorry, should have mentioned, session_start() is called in my base.php file which is included in this file.</p> <p>EDIT</p> <p>I don't know what the problem is, i can assign the variable $email to the other session variable and display that so the user can see who they are logged in as?</p> <p>Does anybody have any suggestions? Both of the other session variables work fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload