Я делаю подобную систему. У меня две страницы: like_but_frame.php и Profile.php.The like_but_frame.php страница работает хорошо, но когда я пытаюсь загрузить ее на страницу Profile.php, она не работает. но когда я нажимаю на него, ничего не происходит, и консоль разработчика не сообщает об ошибке. Какая может быть проблема?
Вот моя страница like_but_frame.php:
<?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, страница имеет больше кода, но я показываю соответствующую часть, чтобы избежать слишком большого количества кода:
<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> $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 /> "; }
Я думаю, вам нужно изменить URL-адрес действия с вашего like_but_frame.php на
<form action="/like_but_frame.php?