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.

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

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元