so i have a zoom.php where i have a link.
<a href='deleteimage.php?imgid={$row['image_id']}'>Delete</a>
if user click on it it goes to deleteimage.php where i have a form. in form i have field where i store imagid.
<form class="form" action = 'deleteimage.php' method = 'post'>
<input type='submit' class='button' value='Yes'>
<input type="hidden" name ="random" class="random" value="<?php echo($_GET['imgid']);?>" />
<br/><br/>
<br/>
<br/>
</form>
now if user click on submit button it run php code. note its still on deleteimage.php page.
if(isset($_SESSION['username'])) /*** user is loged in ***/
{
if($_SERVER['REQUEST_METHOD'] == 'POST') //user hit submit button
{
$user_id_s = $_SESSION['user_id'];
$image_id_g = $_POST['random'];
if(!$tester = mysql_query("SELECT * FROM image WHERE image_id = '$image_id_g' AND user_id = '$user_id_s'"))
{
$del_image = mysql_query("DELETE FROM image WHERE image_id = '$image_id_g'");
$del_comment = mysql_query("Delete From comment Where image_id = '$image_id_g'");
}
here i get a error.
<br /><b>Notice</b>: Undefined index: imgid in <b>C:\xampp\htdocs\a_upload\deleteimage.php</b> on line <b>51</b><br />
note. line 51 is:
<input type="hidden" name ="random" class="random" value="<?php echo($_GET['imgid']);?>" />
.
.
.
so the problem is that:
The first time deleteimage.php is requested, it's with a GET request that includes imgid in the URL. The second time it's requested, it's with a POST request that doesn't have imgid in the URL. So $_GET['imgid'] is undefined.
do to fix this i was going to
You could keep the query string in the post target, or use the post method to get to the form initially.
but have no idea how to do this. any help will be helpful