Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving problems logging in with a single page site
    primarykey
    data
    text
    <p>I am having problems with my login process. I am using sessions and reloading so that I can have a single page site. On Chrome, this adds a ? so the end of the url (anytime the ? is present, login does not work). And on both Firefox and Chrome, the login-logout process only works once and then login stops working. I have an if statement on my index.php page that is essentially:</p> <pre><code>if($_SESSION["LoggedIn"] != true) { /*display login button*/ } else { /*display logout button*/ } </code></pre> <p>Then I set my scripts file:</p> <pre><code> $("#toolbarTitle-Login").click(function() { var loginEmail = $("#toolbarTextbox-Email").val(); var loginPassword = $("#toolbarTextbox-Password").val(); if (loginEmail != "") { $("#toolbarPleaseWait").text("Please wait..."); $.post( 'ajax/loginProcess.php', { 'email': loginEmail, 'password': loginPassword }, function (response) { window.location.reload(true); } ); } }); $("#toolbarTitleLoggedIn-Logout").click(function() { $("#toolbarPleaseWait").text("Logging out..."); $.post( 'ajax/logoutProcess.php', { }, function (response) { window.location.reload(true); } ); }); </code></pre> <p>Then my processing pages loginProcess.php:</p> <pre><code>&lt;?php session_start(); include "../incl/databaseConnection.php"; $email = $connection-&gt;real_escape_string($_POST["email"]); $password = $connection-&gt;real_escape_string(md5($_POST["password"])); $sql = "SELECT clientId FROM clients WHERE (studentEmail = '$email' AND studentPassword = '$password') OR (parentEmail = '$email' AND parentPassword = '$password');"; if (!$result = $connection-&gt;query($sql)) { die ('There was an error running the query [' . $connection-&gt;error . ']'); } $rows = $result-&gt;num_rows; $row = $result-&gt;fetch_assoc(); if ($rows == 1) { $_SESSION["loggedIn"] = true; $_SESSION["clientId"] = $row["clientId"]; } else if ($rows &gt; 1) { echo 'CHOOSE BETWEEN ACCOUNTS'; } else if ($rows == 0) { echo 'SHOW ERROR MESSAGE'; } $connection-&gt;close(); ?&gt; </code></pre> <p>Next logoutProcess.php:</p> <pre><code>&lt;?php session_start(); session_unset(); ?&gt; </code></pre>
    singulars
    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.
 

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