-1
我有一个问题调用PHP函数,当我点击提交按钮:PHP失败,调用函数
<?php
if (isset($_GET['username']) === true and empty($_GET['username']) === false) {
$username = $_GET['username'];
if(user_exists($username) === true) {
$profile_user_id = user_id_from_username($username, 'username');
$my_id = $_SESSION['user_id'];
$profile_data = user_data($profile_user_id, 'username', 'first_name', 'last_name', 'email', 'profile');
?>
<h1><?php echo $profile_data['first_name']; ?>'s Profile</h1>
<?php
if($profile_user_id != $my_id) {
$check_friend_query = mysql_query("SELECT id FROM friends WHERE (user_one='$my_id' AND user_two='$profile_user_id') OR (user_one='$profile_user_id' AND user_two='$my_id')");
if(mysql_num_rows($check_friend_query) > 0) {
echo '<a href="">Already Friends </a>- <a href="">Unfriend '. $profile_data['username'] .'</a>';
} else {
$from_query = mysql_query("SELECT id FROM friend_request WHERE `from` = '$profile_user_id' AND `to` = '$my_id'");
$to_query = mysql_query("SELECT id FROM friend_request WHERE `from` = '$my_id' AND `to` = '$profile_user_id'");
if(mysql_num_rows($from_query) == 1) {
echo '<a href="#">Ignore</a> or <a href="">Accept</a>';
} elseif(mysql_num_rows($to_query) == 1){
echo '<a href="#">Cancel Request</a>';
} else {
if(isset($_GET['submit'])) {
friend_request();
header('Location: '.$profile_user_id);
exit();
}
?>
<form action="">
<input type="submit" name="submit" value="Send friend request!">
</form>
<?php
}
}
}
?>
这最后还有ISSER($ GET [“提交”]和函数调用form.What是错误我不能找到解决办法,它只是刷新页面,但doenst发送的mysql_query功能,我称之为是这样的:
function friend_request() {
if (isset($_GET['username']) === true and empty($_GET['username']) === false) {
$username = $_GET['username'];
if(user_exists($username) === true) {
$profile_user_id = user_id_from_username($username, 'username');
$my_id = $_SESSION['user_id'];
$profile_data = user_data($profile_user_id, 'username', 'first_name', 'last_name', 'email', 'profile');
mysql_query("INSERT INTO friend_request VALUES('', '$my_id', '$profile_user_id')");
}}}
请帮助我,即时通讯新的PHP,这惹恼了我,我一直停留在这个因为昨天晚上试图弄清楚。我真的没有看到问题是什么。如何我更改我的代码吗?一切都完美地期望friend_request()函数的一部分。
谢谢你,但是这仅仅是一个朋友请求按钮,它不要求文本type.Username那我允许在那封锁是为了其他目的。 – user3210494
由于您的代码需要用户名是必需的,您可以将用户名作为隐藏值传递,如'”>' –
仍然只是刷新该页面添加到URL:用户名?用户名=用户名&提交=发送+朋友+请求%21 – user3210494