gpt4 book ai didi

php - 通过 URL 2 Var 发送(1 个已选择且 1 个已登录用户)

转载 作者:行者123 更新时间:2023-11-29 22:34:07 24 4
gpt4 key购买 nike

我正在尝试向页面发送超过 2 个变量 - 1 个是登录用户,另一个是注册用户的 ID,该用户的个人资料由登录用户更新。

我不知道如何更改我的页面。

<?php
include("includes/connect.php");

//logged in users ID from logged in page.
$id = $_GET['id'];

$sql="SELECT * FROM guild_apply";
$result=mysql_query($sql);

?>

<blockquote>
<table border='1' width='100%'>
<tr>
<th>ID </th>
<th>Real Name</th>
<th>Character Name</th>
<th>Class</th>
<th>Rank</th>
</tr>

<?php
while($row = mysql_fetch_array($result)){
?>

//info from all users registered with default rank (which is going to be changed)
<tr>
<td><?php echo $row['id']; ?> </td>
<td><?php echo $row['realname']; ?> </td>
<td><?php echo $row['charname']; ?> </td>
<td><?php echo $row['class']; ?> </td>
<td><?php echo $row['rank']; ?> </td>
<td align="center"><a href="update.php?charname=<?php echo $row['charname']; ?>">update</a></td>
</tr>

<?php
}
?>
</table>
</blockquote>

?>

------更新.php-----

<?php

// Connect to server and select database.
include("connect.php");

$id =$_GET['id'];
$rank =$_POST['rank'];
$charname =$_GET ['charname'];

// update data in mysql database
$sql="UPDATE guild_apply SET rank='$rank' WHERE charname='$charname'" or die ("cant find learner");
$result=mysql_query($sql) or die ("this stuffedup");

if ($result){
// if successfully updated.
header ("Location:../change.php?id=$id");
}else{
echo "Update failed";
}
?>

最佳答案

向 URL 添加 &id= 参数。

<td align="center"><a href="update.php?charname=<?php echo $row['charname']; ?>&id=<?php echo $id; ?>">update</a></td>

关于php - 通过 URL 2 Var 发送(1 个已选择且 1 个已登录用户),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29624609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com