当我将iframe加载到另一个页面时,iframe无法正常工作 [英] iframe is not working when I load it on another page

查看:146
本文介绍了当我将iframe加载到另一个页面时,iframe无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个类似的系统。我有两个页面:like_but_frame.php和Profile.php .like_but_frame.php页面运行良好但是当我尝试将它加载到Profile.php页面时,它不起作用。喜欢按钮出现,但当我点击它时,没有任何反应,开发者控制台不会报告任何错误。可能是什么问题?

I am making a like system.I have two pages;like_but_frame.php and Profile.php.The like_but_frame.php page is working well but when i try to load it into Profile.php page,it does not work.The like button appears but when I click on it,nothing happens and the developer console does not report any error.What might be the issue?

这是我的like_but_frame.php页面:

Here is my like_but_frame.php page:

<?php
include( "Connect.php" ); 
ob_start(); session_start();
if (isset($_SESSION['user_login'])) {
$user = $_SESSION["user_login"];
}
else {
$username = "";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<title></title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</html>
<?php
$id = ""; 
if (isset($_GET['uid'])) {
    $uid = mysqli_real_escape_string($mysqli,$_GET['uid']);
    if (ctype_alnum($uid)) {
$get_likes = $mysqli->query("SELECT * FROM likes WHERE uid='$uid'");
if (mysqli_num_rows($get_likes)===1) {
    $get = mysqli_fetch_assoc($get_likes);
    $uid = $get['uid'];
    $total_likes = $get['total_likes'];
    $total_likes = $total_likes + 1;
    $remove_likes = $total_likes - 2;
    } 
    else
    {
        die("Error ...");
        }
if (isset($_POST['likebutton_'])) {
 $like = $mysqli->query("UPDATE likes SET total_likes='$total_likes' WHERE uid='$uid'");
 $user_likes = $mysqli->query("INSERT INTO user_likes VALUES ('','$user','$uid')");
 header("Location: like_but_frame.php?uid=$uid");
}
if (isset($_POST['unlikebutton_'])) {
 $like = $mysqli->query("UPDATE likes SET total_likes='$remove_likes' WHERE uid='$uid'");
 $remove_user = $mysqli->query("DELETE FROM user_likes WHERE uid='$uid' AND username='$user'");
 header("Location: like_but_frame.php?uid=$uid");
}
 }
}

//Check for previous likes
$check_for_likes = $mysqli->query("SELECT * FROM user_likes WHERE username='$user' AND uid='$uid'");
$numrows_likes = mysqli_num_rows($check_for_likes);
if ($numrows_likes >=1) {
 echo '<form action="like_but_frame.php?uid=' . $uid . '" method="POST">
<input type="submit" name="unlikebutton_' . $id . '" value="Unlike">
<div style="display: inline;">
' . $total_likes . ' likes
</div>
</form>';
}
else if ($numrows_likes == 0) {
echo '
<form action="like_but_frame.php?uid=' . $uid . '" method="POST">
<input type="submit" name="likebutton_' . $id . '" value="Like">
<div style="display: inline;">
' . $total_likes . ' likes
</div>
</form>
';
}
?> 

这是我的Profile.php页面,该页面有更多代码,但我只显示相关部分避免发布太多代码:

Here is my Profile.php page,the page has more code but am showing the relevant part only to avoid posting too much code:

<div class="postForm">
<form action="<? echo $username; ?>" method="POST">
<textarea id="post" placeholder="160 characters limit" name="post" maxlength="160" rows="3" cols="60"></textarea>
<input type="submit" name="send" value="Post" style="background-color: #DCE5EE; float: right; border: 1px solid #666;"/>           
</form>
</div>
<div class="profilePosts">
<?php
$getposts = $mysqli->query("SELECT * FROM posts WHERE user_posted_to='$username' ORDER BY id DESC LIMIT 10") or die(mysqli_error($mysqli));
while ($row = mysqli_fetch_assoc($getposts)) {
$id = $row['id'];
$body = $row['body'];
$date_added = $row['date_added'];
$added_by = $row['added_by'];
$user_posted_to = $row['user_posted_to'];

$get_user_info = $mysqli->query("SELECT * FROM users WHERE username='$added_by'");
$get_info = mysqli_fetch_assoc($get_user_info);
$profilepic_info = $get_info['profile_pic'];
if ($profilepic_info == "") {
$profilepic_info = "./img/default_pic.jpg";
}
else
{
$profilepic_info = "./userdata/profile_pics/".$profilepic_info;
}


echo "
<div style='float: left;'>
<img src='$profilepic_info' height='60'>
</div>
<div class='posted_by'>
<a href='$added_by'>$added_by</a> - $date_added - </div>
&nbsp;&nbsp; 
$body<br /><br /><br />
<iframe src='./like_but_frame.php?uid=$uid' frameborder='0' style='max-height: 70px; width: 20%; min-height: 10px;'></iframe>
<hr />
";

}


推荐答案

我认为你应该将你的行动网址从你的like_but_frame.php改为

I think you should change action url from your like_but_frame.php to

<form action="/like_but_frame.php?

这篇关于当我将iframe加载到另一个页面时,iframe无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆