Note that there are some explanatory texts on larger screens.

plurals
  1. POPage is redirecting to wrong location
    primarykey
    data
    text
    <p>I'm not sure what I did with my code, but for some reason my link to updatestore.php takes me to admin/index.php. Both of the files below reside in localhost/portal/admin, but I can't fathom what is causing the poor behavior. My session_start() variable resides in ../login.php. I tested taking out session_start from that file and all of my other links started behaving in the same way - they would just take me to admin/index.php instead of where they were supposed to go. I'm at a frustrating loss with what to do.</p> <p>This is updatestore.php</p> <pre><code>&lt;?php require ("../login.php"); if ($_SESSION['admin'] != 1) header('Location: ../index.php'); if (isset($_POST['submit'])) { $_SESSION['store'] = $_POST['store']; header('Location:updatestore2.php'); } include ("header.php"); include ("adminnav.php"); ?&gt; &lt;h2&gt;Update Store&lt;/h2&gt; &lt;?php $stmt = $db-&gt;prepare("SELECT short_name FROM store ORDER BY short_name"); $stmt-&gt;execute(); $rows = $stmt-&gt;fetchAll(); $num_rows = count($rows); if ($num_rows == 0) echo '&lt;p&gt;There are no store\'s currently in the system.'; else { ?&gt; &lt;form action="" method="post"&gt; &lt;ul&gt; &lt;li&gt; &lt;b&gt;Select Store To Edit:&lt;/b&gt;&lt;br&gt; &lt;select name="store"&gt; &lt;?php foreach($rows as $row) { echo '&lt;option value ="'. $row['short_name'] . '"&gt;' . $row['short_name'] . '&lt;/option&gt;'; } ?&gt; &lt;/select&gt; &lt;/li&gt; &lt;li&gt; &lt;br&gt;&lt;input type="submit" value="Select Store" name ="submit" id="submit"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; &lt;?php } ?&gt; &lt;?php include ("footer.php"); ?&gt; </code></pre> <p>This is another page that works correctly, addshortages.php</p> <pre><code>&lt;?php require ("../login.php"); if ($_SESSION['admin'] != 1) header('Location: ../index.php'); $success = false; if (isset($_POST['submit'])) { $_SESSION['store'] = $_POST['store']; header('Location: addshortages2.php'); } include ("header.php"); include ("adminnav.php"); ?&gt; &lt;h2&gt;Update Shortages List&lt;/h2&gt; &lt;?php if (!empty($errors)) foreach($errors as $error) echo $error; if ($success == true) echo '&lt;p&gt;The FAQ has succesfully been submitted!&lt;/p&gt;'; ?&gt; &lt;?php $stmt = $db-&gt;prepare("SELECT * FROM store ORDER by short_name"); $stmt-&gt;execute(); $rows = $stmt-&gt;fetchAll(); $num_rows = count($rows); ?&gt; &lt;?php if ($success == false) { ?&gt; &lt;form action="" method="post"&gt; &lt;ul&gt; &lt;li&gt; &lt;b&gt;Select Store To Modify Shortages:&lt;/b&gt;&lt;br&gt; &lt;select name="store"&gt; &lt;?php foreach($rows as $row) { echo '&lt;option value ="'. $row['short_name'] . '"&gt;' . ($row['short_name']) . '&lt;/option&gt;'; } ?&gt; &lt;/select&gt; &lt;/li&gt; &lt;li&gt; &lt;br&gt;&lt;input type="submit" value="Select Store" name ="submit" id="submit"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; &lt;?php } ?&gt; &lt;?php include ("footer.php"); ?&gt; </code></pre> <p>I also have the issue where I try to log-out of my pages, but they just take me to admin/index.php as well. The log-out appends ?logout=1 to a GET variable, but it isn't doing what it is supposed to.</p> <p>index.php</p> <pre><code>&lt;?php require ("login.php"); require_once ('Bcrypt.php'); if ((isset($_GET['logout'])) == 1) { session_destroy(); header('Location: ../index.php'); } if (isset($_SESSION['user'])) { if ($_SESSION['admin'] == 1) header('Location: admin/index.php'); else header('Location: customer/index.php'); } if (isset($_POST['submit'])) { if ((empty($_POST['email'])) || (empty($_POST['password']))) $errors[] = 'Please fill out all fields of the registration process.&lt;br&gt;'; else { $email = trim($_POST['email']); $password = trim($_POST['password']); $stmt = $db-&gt;prepare("SELECT * FROM users WHERE email=:email"); $stmt-&gt;bindValue(':email', $email, PDO::PARAM_STR); $stmt-&gt;execute(); $rows = $stmt-&gt;fetchAll(); $num_rows = count($rows); if ($num_rows) { foreach($rows as $row) { $result = Bcrypt::checkPassword($password,$row['password']); if ($result) { $_SESSION['user'] = $row['id']; $_SESSION['admin'] = $row['admin']; $_SESSION['name'] = $row['name']; $_SESSION['email'] = $row['email']; if ($_SESSION['admin'] == 1) header('Location: admin/index.php'); else header('Location: customer/index.php'); } else $errors[] = 'Your password is incorrect. Please try again.'; } } else $errors[] = 'We do not have a record of your credentials in our system. To register go &lt;a href="register.php"&gt;here&lt;/a&gt;. '; } } include ("header.php"); include ("subnav.php"); ?&gt; &lt;h2&gt;System Log-In&lt;/h2&gt; &lt;?php if (!empty($errors)) foreach($errors as $error) echo $error; ?&gt; &lt;form action="" method="post"&gt; &lt;ul&gt; &lt;li&gt; &lt;b&gt;E-Mail:*&lt;/b&gt; &lt;br&gt; &lt;input type="text" name="email"&gt;&lt;/li&gt; &lt;li&gt; &lt;b&gt;Password:*&lt;/b&gt; &lt;br&gt; &lt;input type="password" name="password"&gt; &lt;/li&gt; &lt;li&gt; &lt;br&gt;&lt;input type="submit" value="Log-In" name ="submit" id="submit"&gt; &lt;/li&gt; &lt;li&gt; &lt;br&gt;&lt;a href="register.php"&gt;Activate Account Here.&lt;/a&gt; &lt;/li&gt; &lt;li&gt; If you are having problems with the log-in process, please send us an &lt;a href="mailto:jayl@jays.us"&gt;e-mail&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; &lt;?php include ("footer.php"); ?&gt; </code></pre> <p>I have tested this situation on IE, Firefox, and Chrome. The updatestore.php file only does NOT work on Firefox. I have no idea why this might be. Also, for IE and Chrome, I have to click the log-out link TWICE before the page logs out and goes to the appropriate location. I'm pulling my hair out here.</p>
    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.
 

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