Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Login Script:</p> <pre class="lang-php prettyprint-override"><code>$username = $_POST['username']; $password = $_POST['password']; $password = sha1($password); if ($username&amp;&amp;$password) { require_once('../db/nstDBconnector.php'); $qr = "SELECT * FROM `users` WHERE `username` = '$username'"; $query = mysql_query($qr); $numrows = mysql_num_rows($query); if ($numrows!=0) { // check password against the password in the database while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { $storedUsername = $row['username']; $storedPassword = $row['password']; $storedUserType = $row['user_type']; $storedUserFName = $row['full_name']; $_SESSION['last_ip'] = $_SERVER['REMOTE_ADDR']; } // check to see if username and password match if ($username==$storedUsername&amp;&amp;$password==$storedPassword) { ob_start(); session_start(); $_SESSION['username'] = $storedUsername; $_SESSION['user_type'] = $storedUserType; $_SESSION['full_name'] = $storedUserFName; header ('Location: main.php?login=successful'); } else { header ('Location: index.php?error=incorrectPassword'); } } else { header ('Location: index.php?error=noUser'); } } else { header ('Location: index.php?error=missingUserAndPass'); } </code></pre> <p>The page you are taking them to after login:</p> <pre class="lang-php prettyprint-override"><code>if ($_SESSION['username']) { $userLogged = $_SESSION['username']; $userType = $_SESSION['user_type']; $userFName = $_SESSION['full_name']; } else { header ('Location: http://www.yourdomain.com/index.php?error=notLoggedIn'); } </code></pre> <p>Where you want to show user name on the page:</p> <pre class="lang-html prettyprint-override"><code>Logged in as &lt;?php echo $userFName; ?&gt;. </code></pre> <p>or</p> <pre class="lang-php prettyprint-override"><code>echo "Logged in as ", $userFName, "."; </code></pre>
    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.
    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