Moorcam Posted July 16, 2017 Share Posted July 16, 2017 (edited) Howdy folks, This is beating me to death very slowly. I have set the sessions but one in particular is giving me an undefined index: <div class="modal-body"> <?php if (isset($_SESSION['fname'])) { ?> <p><strong>First Name:</strong> <?php echo $_SESSION['fname']; ?></p> <?php } if (isset($_SESSION['lname'])) { ?> <p><strong>Last Name:</strong> <?php echo $_SESSION['lname']; ?></p> <?php } if (isset($_SESSION['admin_email'])) { ?> <p><strong>Email:</strong> <?php echo $_SESSION['admin_email']; ?></p> <?php } if (isset($_SESSION['phone'])) { ?> <p><strong>Phone:</strong> <?php echo $_SESSION['phone']; ?></p> <?php } ?> </div> I am getting Undefined index 'phone' on this line: <?php echo $_SESSION['phone']; ?> This is where I have them set: $result = mysqli_query($mysqli, "SELECT user_id, admin_email, fname, lname, phone FROM admin_users WHERE admin_email = '" . $admin_email. "' and admin_password = '" .$admin_password . "'"); if ($row = mysqli_fetch_assoc($result)) { $_SESSION['user_id'] = $row['user_id']; $_SESSION['admin_email'] = $row['admin_email']; $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; $_SESSION['phone'] = $row['phone']; header("Location: index.php"); } else { $errormsg = "Incorrect Email or Password Combination!"; } } $mysqli->close(); ?> All other variables are showing without issue. Just that one. Any ideas before I throw a tanty? Edited July 16, 2017 by DanEthical Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 16, 2017 Share Posted July 16, 2017 I don't see anything that explains what you are seeing. At the top of that script, after session_start(), var_dump($_SESSION); and see what it has in it. Quote Link to comment Share on other sites More sharing options...
Moorcam Posted July 16, 2017 Author Share Posted July 16, 2017 I don't see anything that explains what you are seeing. At the top of that script, after session_start(), var_dump($_SESSION); and see what it has in it. It has all of them except for that one: array(5) { ["user_id"]=> string(1) "2" ["admin_email"]=> string(23) "***" ["fname"]=> string(5) "***" ["lname"]=> string(9) "***" ["active"]=> NULL } Obviously I have replaced data with *** for privacy. No idea where ["active"]=> NULL is coming from. It's not in the DB. Quote Link to comment Share on other sites More sharing options...
Solution Moorcam Posted July 16, 2017 Author Solution Share Posted July 16, 2017 (edited) Got it. The issues was me being stupid. I will not go there Edited July 16, 2017 by DanEthical 1 Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 16, 2017 Share Posted July 16, 2017 I figured there was some Pebkac involved. Happens to everyone at some point. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.