用户登录后,表单和div不会显示

时间:2019-02-15 14:54:54

标签: javascript php session

即使用户未登录,此表单仍显示在我的页面上。我决定仅在用户登录后才显示该表单。当我正确注销时,它会显示else语句{您尚未登录}当我登录“ else语句”后消失了,但是,该页面是空白的,没有显示表格。我在做什么错

 <?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">&times;</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
  }
  ?>

1 个答案:

答案 0 :(得分:0)

我知道了。我需要用

替换isset($ sessions ..)
if(isset($_SESSION['iduser']) && $_SESSION['iduser']==true)