Bootstrap模态值无法传递到另一个页面

时间:2016-07-09 23:42:01

标签: php jquery twitter-bootstrap

您好我将变量传递给另一个页面,但我得到Undefined index: titles in C:\xampp\htdocs\studentportal\edit2.php on line 6错误有人可以帮我吗?我不知道为什么会出错。

这是模态

中的表单
   <form method="POST" enctype="multipart/form-data" action ="edit2.php">
    <div class="form-group">
      <label for="title">News Title</label>
       <input type="text" name="titles" class="form-control title" id="title" placeholder="News Title" value="<?php echo $row['news_title']; ?>">
        </div>

       <div class="form-group">
         <label for="date">Date</label>
          <input type="text" name="dates" class="form-control date" id="date" placeholder="Date" value="<?php echo $row['news_date']; ?>"s>
           </div>

        <div class="form-group">
          <label for="content">News Content</label>
     <textarea class="form-control content" name="contents" rows="5" id="content"><?php echo $row['news_content']; ?></textarea>
        </div>


  <img id="blah" src="<?php echo $row['news_image']; ?>" width="200px" height="140px"/>
  <input id="image" name="image" class="fileupload" type="file" accept="image/*"/>

   </div>

     <div class="modal-footer">
     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
     <a class='btn btn-info left-margin' href="edit2.php?newsid=<?php echo $row['news_id'];?>">Yes</a>
     </form>

这是edit2.php

<?php

    include_once('connection.php');
        $newsid = $_GET['newsid'];
          echo $_POST['titles'];



        ?>

1 个答案:

答案 0 :(得分:2)

<a>元素未提交POST请求,而是提交GET请求。因此,$_POST将为空。

尝试使用此代替<a>元素:

<button type="submit" class='btn btn-info left-margin'>Yes</button>

并将表单操作更改为edit2.php?newsid=<?=$row['news_id']?>