にデータを挿入しないと、これは私が作成したものです 私は唯一のindex.phpであり、それはフォームと接続し、クエリを挿入している1つのファイルを作成しました。データベースにデータを挿入しません。間違いや欠けているものがあるかどうか確認してください。それはmysqlの
このコードいくつかのエラーでindex.phpを
<html>
<head>
<title>Percision Inventory</title>
</head>
<body>
<h2>Input Machine</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="index.php">
Serial ID: <input type="text" name="serialId">
<br><br>
Name: <input required type="text" name="name">
<br><br>
Manufacturer: <input type="text" name="manufacturer">
<br><br>
Keys: <textarea name="licensekeys" rows="5" cols="40"></textarea>
<br><br>
Description: <textarea name="description" rows="5" cols="40"></textarea>
<br><br>
Category: <input type="text" name="category">
<br><br>
Block (A or B): <input type="text" name="block">
<br><br>
Floor (1, 2, Ground): <input type="text" name="floor">
<br><br>
Room: <input type="text" name="room">
<br><br>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
$servername = "localhos";
$username = "abc";
$password = "dfg";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$sql = "INSERT INTO products (serialid, name, manufacturer, licensekeys, description, categoryname,block, floor, room) VALUES ('".$_POST['serialid']."','".$_POST['name']."','".$_POST['manufacturer']."','".$_POST['licensekeys']."','".$_POST['description']."','".$_POST['category']."','".$_POST['block']."','".$_POST['floor']."','".$_POST['room']."')";
if (!$stmt = $con->prepare($sql))
die('Query failed: (' . $con->errno . ') ' . $con->error);
?>
</body>
</html>
どのようなエラーが表示されますか? – Mureinik
接続変数は、$ conn'ない '$ con' – Saty
' $サーバー名=「localhos」 ''です...これは、あなたが必ずあなたのサーバが '末尾に 'T'とlocalhost'されていないされている奇妙な名前です。 ? –