Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Login page</p> <pre><code>&lt;?php session_start(); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new mysqli("localhost", "", "", ""); //if post and encryption if(isset($_POST['Submit'])){ $userEmail=strip_tags(trim($_POST['userEmail'])); $userPassword=SHA1(trim($_POST['userPassword'])); //Check to see if the user left any space empty! For browsers that do not support the HTML5 'required' atribute. if($userEmail==""||$userPassword=="") { $error="Please fill in all of the information"; } else { if ($stmt = $mysqli-&gt;prepare("SELECT userID FROM users WHERE userEmail = ? and userPassword = ? LIMIT 1")) { $stmt-&gt;bind_param("ss", $userEmail, $userPassword); $stmt-&gt;execute(); $stmt-&gt;store_result(); if($stmt-&gt;num_rows &gt; 0) { $_SESSION['Email'] = $userEmail; $stmt-&gt;close(); //go to next page header ("location: nextpage.php"); } $error="Email and Password do not match, please try again."; } }} ?&gt; &lt;!DOCTYPE html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;!--Display errors--&gt; &lt;div class="errorbox"&gt; &lt;?php if(isset($error)){?&gt;&lt;strong class="error"&gt;&lt;?php echo $error;?&gt;&lt;/strong&gt;&lt;?php } ?&gt; &lt;/div&gt; </code></pre> <h2>Login</h2> <pre><code> &lt;form action="#" name="loginform" method="post" &gt; &lt;!--change input type to email if desired but then Spanish accented characters will fail validation --&gt; &lt;label&gt;Email &lt;/label&gt; &lt;input type="text" class="styleinput" name="userEmail" maxlength="50" title="Enter Your email" autocomplete="off" placeholder="enter email" required/&gt;&lt;br /&gt; &lt;label&gt;Password &lt;/label&gt; &lt;input type="password" class="styleinput" name="userPassword" maxlength="50" title="Enter Your Password" autocomplete="off" placeholder="enter password" required/&gt; &lt;a href="help.php" class="stylelink"&gt; Forgot your password? &lt;/a&gt; &lt;input type="submit" name="Submit" class="stylesubmit" value="Submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>every other page that user must be logged in</p> <pre><code>&lt;?php session_start(); if(!isset($_SESSION['Email'])){ header("location:home.php"); } ?&gt; </code></pre> <p>your code - Also edit above code to fit your site and don't forget to encrypt password on registration page.</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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