我花了几个小时尝试调试这个无用。如果有人可以告诉我如何解决这个问题而不实际给我代码。 (我喜欢学习)。那太棒了。
表格部分:
<form method="POST" action="./updatelink.php">
<label for="link" style="color: #678098; font-size: 17pt;font-family: roboto;">Your Steam Trade URL: </label>
<input type="text" name="link" class="form-control trade-url-input" style="" id="link" value="<?php echo fetchinfo("tlink","users","steamid",$_SESSION["steamid"]); ?>" placeholder="Link exchange">
<p>Fetch your Steam URL:
<a href="http://steamcommunity.com/id/me/tradeoffers/privacy#trade_offer_access_url" target="_blank" style="color: #678098; font-size: 12pt;font-family: roboto;">http://steamcommunity.com/id/me/tradeoffers/privacy</a>
</p>
<p style="color: #FF3F3F; font-size: 12pt;font-family: roboto;">Make sure your Steam URL is Valid!</p>
<p style="color: #FF3F3F; font-size: 12pt;font-family: roboto;">Entering an invalid URL would prevent you from getting your winnings!</p>
<input type="submit" class="btn btn-primary btn-lg" href="#" value="Save">
</form>
UpdateLink文件
<?php
@include_once('set.php');
@include_once('steamauth/steamauth.php');
if(!isset($_SESSION["steamid"])) {
Header("Location: index.php");
exit;
}
$link = $_POST["link"];
$link = mysqli_real_escape_string($link);
$steam = $_SESSION["steamid"];
if($result = mysqli_query( "UPDATE `users` SET `tlink`='$link' WHERE `steamid`='$steam'"))
{
printf($result);
}
Header("Location: settings.php");
exit;
?>
答案 0 :(得分:3)
这里有两件事:
mysqli_real_escape_string()
mysqli_query()
。这两个函数都需要将数据库连接作为第一个参数传递。
另外,您的连接要求它是mysqli_
,而不是任何其他API。
还要确保使用会话在所有文件中启动会话。
检查错误:
另外,在打开<?php
标记之前查看这些空格;确保你没有在标题之前输出。
然后你有一个href="#"
:
<input type="submit" class="btn btn-primary btn-lg" href="#" value="Save">
要验证UPDATE确实成功,请使用mysqli_affected_rows()
。