Note that there are some explanatory texts on larger screens.

plurals
  1. POmaking php response to remain visible when page refresh
    text
    copied!<p>It is all working fine in my login-script. I get the right responses in my div (id=login_reply) and the session starts. But whenever I refresh the page, the login_reply is gone. How am I able to keep the login_reply? Thank you!</p> <p>Here is the php: </p> <pre><code>if (isset($_POST['username'], $_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $check = mysql_query("SELECT * FROM `userbase` WHERE `user_name` = '$username'"); if (mysql_num_rows($check) &gt; 0) { while ($row = mysql_fetch_assoc($check)) { $user_id = $row['user_id']; $user_name = $row['user_name']; $user_email = $row['user_email']; $user_password = $row['user_password']; if ($password == $user_password) { $_SESSION['user_id'] = $user_id; if (isset($_SESSION['user_id']) &amp;&amp; $_SESSION['user_id'] != '') echo "Welcome back '$user_name'!"; else { echo 'no'; } } else echo 'no'; } } else echo 'no'; } </code></pre> <p>Here is the jQuery</p> <pre><code>$(document).ready(function() { $('#login').click(function() { var username = $('#username').val(); var password = $('#password').val(); $.ajax( { type: 'POST', url: 'php/login.php', data: 'username=' +username + '&amp;password=' + password, success: function(data) { if (data != 'no') { $('#logform').slideUp(function() { $('#login_reply').html(data).css('color', 'white'); }); } else $('#login_reply').html('Invalid username or password').css('color', 'red'); } }); return false; }); }); </code></pre>
 

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