-1

我的表单当前将用户带到 usersearch.php,但 URL 中的数据没有参数。

我该怎么做:

usersearch.php

为此?

usersearch.php?username=myAwesomeUsername

这是我的脚本:

<? $user=$_POST["user"]; ?>
<form name="form" action="usersearch.php" method="post">
Username: 
<input type="text" name="user" value="<?echo($user)?>">
<input type="submit">
</form>
<fieldset><!--30-->
<?
$query1="SELECT * FROM users WHERE username LIKE '".mysql_real_escape_string($user)."%' ";
echo("<hr color='red'>Username Results: $user<br><br>");
if(!$user == "")
{
$result1=mysql_query($query1,$con);
while ($row1 = mysql_fetch_object($result1))
{
echo "Username: [".$row1->username."]<br>";
echo "User level: [".$row1->level."]<br>";
echo "User status: [".$row1->status."]<br>";
echo "User email: [".$row1->email."]<br>";
echo "User Bio: [".$row1->bio."]<hr>";
}
}else{
Echo "";
}
4

1 回答 1

3

要获取 URL 上的 ?username= 部分,您需要将表单方法更改为 GET:

<form name="form" action="usersearch.php" method="get">
于 2013-02-12T19:53:18.407 回答