Yukihira Soma
Yukihira Soma

Reputation: 153

Bootstrap modal values cant pass to another page

Hello im passing the variable to another page but im getting an error of Undefined index: titles in C:\xampp\htdocs\studentportal\edit2.php on line 6 Can someone help me? i dont know why it getting an error.

here is the form in the modal

   <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>

here is the edit2.php

<?php

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



        ?>

Upvotes: 1

Views: 198

Answers (1)

1sloc
1sloc

Reputation: 1180

You <a> element is not submitting a POST request, but a GET request. As such, $_POST will be empty.

Try this instead of the <a> element:

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

and change the form action to edit2.php?newsid=<?=$row['news_id']?>

Upvotes: 2

Related Questions