-1
我創建了一個表單,當我提交值時我想插入mysql數據庫,但是當我點擊提交按鈕數據庫不更新..不知道我要去哪裏錯了我的代碼..無法通過表單數據插入mysql數據庫
<html>
<head>
<title>Form Data</title>
</head>
<body>
<form action="form.php" method="post">
Server Name: <input type="text" name="server_name"> <br />
IP Address: <input type="text" name="ip_address"> <br />
Server Role: <input type="text" name="server_role"> <br />
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])) {
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "abcx";
$dbname = "serverasset_inventory";
$connection = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
$sql = "INSERT INTO asset_inventory (server_name,ip_address,server_role)
VALUES ('$_POST[server_name]','$_POST[ip_address]'),'$_POST[server_role]')";
$state = mysqli_query($connection,$sql);
mysqli_close($connection);
}
?>
</body>
</html>
任何幫助?
-A
Bec因爲你不是'更新'你'插入' –
對不起,錯字..我的意思是插入..它仍然很早,我想解決這個問題! – Alstarmania
Stackoverflow不是一個地方來調試你的錯誤..!請在這裏發佈問題之前做一些調查。這個問題似乎是一個入門級的基本語法錯誤。沒有任何顯示的研究努力的跡象 –