I am trying to execute a simple 'get' form within an iframe like so:
<iframe width = 60% height= 100% id="dynamic-content" src="imageViewing.php" />
This is the imageViewing.php:
<html>
<meta http-equiv="refresh" content="8">
<?php
//*database conncetion settings*
$query = "SELECT team_name,id,content FROM upload WHERE display='1'";
$result = mysql_query($query) or die('Error, query failed'.mysql_error());
while ($row = mysql_fetch_assoc($result))
{
$id = $row['id'];
echo $row['id']. '<img width="200" height = "200" src="data:image/png;base64,' . base64_encode($row['content']) . ' " />'. $row['team_name']."<form method='get' action='imgApproved.php?id='$id'><input type='submit' value='Approve'/></form><br>";
}
exit;
mysql_close();
?>
</html>
Clicking the button runs the imgApprove.php, which changes the 'display' parameter for the specific image, so that it doesn't display the next time the iframe refreshes.
<?php
if (isset($_GET['id']))
{
$id = $_GET['id'];
//*Connect to database stuff*
$query = "UPDATE upload SET display='0' WHERE id='$id'";
$result = mysql_query($query) or die('Error, query failed'.mysql_error());
header("location:imageViewing.php");
}
?>
However, when I click on Approve, the iframe stops refreshing and no longer displays anything. However, if I refresh the page all the images are still displayed (so I assume imgApprove.php hasnt changed the value of display). Am I missing something simple here?
EDIT I have been doing some further testing and as it turns out: if (isset($_GET['id']))
is returning false and not even running the code, so the problem must be in the passing of the $id variable.
</div>