[英]The form and divs will not show when user is logged in
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. 即使用户未登录,此表单仍显示在我的页面上。我决定使该表单仅在用户登录后才可见。当我正确注销时,它会正确显示else语句{您尚未登录}和当我登录“ else语句”后消失,但是,该页面为空白并且没有显示该表单。 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
我需要将isset($ sessions ..)替换为
if(isset($_SESSION['iduser']) && $_SESSION['iduser']==true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.