所以前段时间我在我的"编辑个人资料"上寻求答案。页。 现在我改变了很多,但它没有更新表中的任何内容。 有人可以帮忙吗? 如果您想测试该页面,请检查:http://joshnet.tk/edit.php 这是代码:
编辑:将mysql_connect更改为mysqli_connect
EDIT2:将mysql_error()添加或复制到mysql_query
EDIT3:也改变了mysql_close& mysql_query到mysqli _...
<?php
session_start();
if(!isset($_SESSION['username'])){
header('Location: index.php');
}
else{
}
include_once('config.php');
include_once('functions.php');
if(isset($_POST['verzonden'])){
$fout_bericht = '';
mysqli_connect($host, $gebruiker, $wachtwoord, $database) or die (mysql_error());
$naam = $_POST['username'];
$user = $_POST['user'];
$id = $_SESSION['id'];
$strSQL = "Update members set ";
if(check_field($_POST['username'], T_TEXT)){
$strSQL = $strSQL . "naam= '$naam', ";
}
if(check_field($_POST['user'], T_TEXT)){
$strSQL = $strSQL . "user= '$user', ";
}
elseif($_POST['naam'] == ($_POST['user'])){
$fout_bericht .= "You must fill in at least one field!";
}
if($fout_bericht){
echo " <html><head><link rel=\"stylesheet\" href=\"css/style.css\" /></head><body><h1>";
echo $fout_bericht . "<br/></h1>";
echo "<a class=\"btn btn-lg btn-success\" href=\"edit.php\"><i class=\"fa fa-refresh fa-spin fa-2x\"></i> <h1>Try again</h1></a></body></html>";
}
else{
$strSQL = $strSQL . "Where id = '$id'";
// The SQL statement is executed
mysqli_query($strSQL) or die (mysql_error());
// Close the database connection
mysqli_close();
header("Refresh: 3; url=view.php");
echo "Edited Profile Succesfully!";
echo "You will be redirected to Home in 3 seconds...";
}
} else{
?>
-HTML CODE-
<?php } ?>