douchi5822 2015-08-17 06:17
浏览 116
已采纳

iframe中的表单无法正常运行

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>

展开全部

  • 写回答

1条回答 默认 最新

  • dpq59734 2015-08-25 00:50
    关注

    I believe the issue was caused by an unclosed iframe. I needed to add </iframe> after the <iframe> declaration. Anything in between the two is the text displayed if the iframe fails to load.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 fluent设置了自动保存后,会有几个时间点不保存
  • ¥20 激光照射到四象线探测器,通过液晶屏显示X、Y值
  • ¥15 这怎么做,怎么在我的思路下改下我这写的不对
  • ¥50 数据库开发问题求解答
  • ¥15 安装anaconda时报错
  • ¥20 如何用Python处理单元格内连续出现的重复词语?
  • ¥15 小程序有个导出到插件方式,我是在分包下引入的插件,这个export的路径对吗,我看官方文档上写的是相对路径
  • ¥20 希望有人能帮我完成这个设计( *ˊᵕˋ)
  • ¥100 将Intptr传入SetHdevmode()将Intptr传入后转换为DEVMODE的值与外部代码不一致
  • ¥50 基于ERA5数据计算VPD