Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent an administrator from logging in twice?
    primarykey
    data
    text
    <p>I don't want to show the administrator the login page if they're already logged in. What should I do if I want to redirect the administrator to the homepage when they go to the administrator login page. For your information, I have included the <code>header.php</code> into every administrator pages after the administrator has logged in. Your help is very much appreciated! Thank you! </p> <p>Below shows a part of my <code>header.php</code> coding:</p> <pre><code>&lt;?php session_start(); if(!isset($_SESSION['name']) or (!isset($_SESSION['password'])) or $_SESSION['name'] == '' or $_SESSION['password'] == '' ) { header('Location: index.php'); } ?&gt; </code></pre> <p>Below shows my administrator login page coding:</p> <pre><code>&lt;form method="post" action="login_now.php" name="form1" id="form1" onSubmit="MM_validateForm('Name','','R','Password','','R','Security_code','','R');return document.MM_returnValue"&gt; &lt;table style="width: 100%;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="text-align: center;" rowspan="4"&gt;&lt;img src="../admin/images/login.png" alt="Please enter your login details."&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Username&lt;span class="required"&gt;*&lt;/span&gt; &lt;br&gt; &lt;input type="text" class="form-control" style="width: 150px; height: 20px" name="Name" id="Name" class="inputstyle"/&gt; &lt;br&gt; &lt;br&gt; Password&lt;span class="required"&gt;*&lt;/span&gt; &lt;br&gt; &lt;input type="password" class="form-control" style="width: 150px; height: 20px" name="Password" id="Password" class="inputstyle"/&gt; &lt;br&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;br&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right" width="240px"&gt; &lt;input type="submit" value="Login" class="buttons" /&gt; </code></pre> <p>Below shows my <code>login_now.php</code> coding:</p> <pre><code>&lt;?php session_start(); ob_start(); include("../DBScripts/DB.php"); $adminName = $_POST['Name']; $adminPassword = $_POST['Password']; $Security = $_POST['Security_code']; $hidden = $_POST['Security_required']; $conn = dbConnect(); if (!$conn) die("Couldn't connect to MySQL"); $query = "select * from user where usernm='$adminName' and userpw='$adminPassword'"; $result = mysql_query($query, $conn); $row = mysql_fetch_array($result); if (mysql_num_rows($result) &gt; 0 &amp;&amp; $row['userty']== user &amp;&amp; $Security == $hidden) { $_SESSION['name'] = $adminName; $_SESSION['password'] = $adminPassword; header ('Location: ../Users/home_user.php'); } else if(mysql_num_rows($result) &gt; 0 &amp;&amp; $row['userty']== admin &amp;&amp; $Security == $hidden) { $_SESSION['name'] = $adminName; $_SESSION['password'] = $adminPassword; header('Location: adminindex.php'); } else { header('Location: index.php'); } ?&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