好吧,我正在尝试编写一个添加朋友脚本并且他正在工作,但是当我的脚本(即在函数中)尝试搜索$_GET['id']
以查看配置文件的 id 以提出好友请求时,脚本不能find because 是 profile.php 中的一个函数,而不是直接在文件中。
因此,如果我设置$_GET
会话,我可以进行,但是如果我输入用户配置文件然后进入另一个配置文件,并且如果我尝试向第一个配置文件发出好友请求,则请求将发送到最后一个(即已注册在会话中)
那么我怎样才能做一个$_GET
“全球性的”呢?
那是我的代码:
OTHER_PROFILE.PHP
<?php include_once("includes/head.php"); ?>
<?php require_once("includes/connect/connect.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php get_directory() ?>
<?php login_validation() ?>
<?php first_login(); ?>
<?php count_logins(); ?>
<?php get_shortcuts_menu_by_user(); ?>
<?php include_once("includes/body.php"); ?>
<?php
global $userid;
global $userid_profilee;
$_SESSION['userid'] = $userid;
$_SESSION['id'] = $_GET['id'];
?>
<script src="alert.js" ></script>
<?php
other_profile_main_photo();
echo "<br><br>";
?>
<?php include_once("includes/body_begin.php"); ?>
<?php echo "<br><br>";?>
<?php include("includes/footer.php"); ?>
FUNCTIONS.PHP (只是函数部分)
<?php require_once("/connect/connect.php"); ?>
<?php require_once("/jquery.php"); ?>
<?php
######### FRIEND REQUEST ########
function friend_request_send(){
global $db;
global $userid;
$userid = $_SESSION['userid'];
$userid_profilee = $_SESSION['id'];
$query_id_requester = "SELECT * FROM friend_requests";
$result_set1 = mysql_query($query_id_requester, $db) or die(mysql_error()) ;
$query_id_requests = "SELECT friend_requests FROM members WHERE id=\"{$userid_profilee}\" ";
$result_set3 = mysql_query($query_id_requests, $db) or die(mysql_error());
$query_id_requester_check = "SELECT * FROM friend_requests WHERE user_id=\"{$userid_profilee}\"";
$result_set4 = mysql_query($query_id_requester_check, $db);
$query_id_user_check = "SELECT * FROM friend_requests WHERE user_id_requester=\"{$userid}\"";
$result_set5 = mysql_query($query_id_user_check, $db);
## If already exists a friend request do this:
if ($id_requests = mysql_fetch_array($result_set3)){
if (($id_requester_check = mysql_fetch_array($result_set4)) && ($id_user_check = mysql_fetch_array($result_set5))){
echo "Ja fizeste pedido de Amizade!";
return ;
}
else
{
}
}
if ($id_requester = mysql_fetch_array($result_set1)){
$id_requests_1 = $id_requests['friend_requests'] + 1;
mysql_query("UPDATE members SET friend_requests=\"{$id_requests_1}\" WHERE id=\"{$userid_profilee}\"");
mysql_query("INSERT INTO friend_requests (user_id, user_id_requester) VALUES (\"{$userid_profilee}\", \"{$userid}\")");
echo "<div class=\"nNote nSuccess hideit\">
<p><strong>SUCCESS: </strong>Pedido de Amizade enviado com sucesso!</p>
</div>";
}
else
{
echo "Pedido de Amizade nao enviado!";
}
}
如果我尝试更改$userid_profilee = $_SESSION['id'];
为$userid_profilee = $_GET['id'];
注意:未定义的索引:第 13 行 C:\xampp\htdocs\includes\functions.php 中的 id