Yukihira Soma Yukihira Soma - 10 months ago 37
jQuery Question

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

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

here is the edit2.php


$newsid = $_GET['newsid'];
echo $_POST['titles'];



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']?>