douchi5822 2015-08-17 14: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 08: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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看