This form was displaying on my page even when a user is not logged in. I decided to make it only visible after the user has logged in. When I log out it correctly shows the else statement {You are not logged in} and when I log in the "else statement" goes away, HOWEVER, the page is blank and doesn't show the form. What am I doing wrong
<?php if($_SESSION["iduser"] == "yes") { ?>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title" style="color:green;">POST IT! </h4>
</div>
<div class="modal-body">
<select class="form-control" name="idpostcategory" required>
<option value="">Select Category</option>
<?php
$sql = "SELECT * from postcategories order by idpostcategory";
if ($result = mysqli_query($conn, $sql)) {
while ($row = $result->fetch_assoc()) { if($row['idpostcategory'] != '1'){ ?>
<option value="<?php echo $row['idpostcategory']; ?>"><?php echo
$row['strongtext']; ?> (<?php echo $row['normaltext']; ?>)</option>
<?php } }
}
?>
</select>
</div>
<div class="modal-body">
<input maxlength="30" class="form-control" id="postheading" name="postheading" rows="3" placeholder="Post Heading..." required></input>
</div>
<div class="modal-body">
<textarea maxlength="420" class="form-control" id="posttext" name="posttext" rows="3" placeholder="Enter ..." required></textarea>
</div>
<div class="modal-footer">
<button type="button" id="closemodal" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-outline">Post</button>
</div>
</div>
<?php } else { ?>
<p> You ARE NOT logged in. </p>
<?php
}
?>
I figured it out. I needed to replace the isset($sessions..) with
if(isset($_SESSION['iduser']) && $_SESSION['iduser']==true)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.