我具有以下应该启动RegOrdre.php文件的HTML,但是目前看来,它所要做的就是将我重定向到RegOrdre.php文件并显示空白页面。
<form action="/RegOrdre.php" method="post">
<p><label class="label">Navn</label>
<input name="Navn" type="text" class="input"></p>
<p><label class="label">Email</label>
<input name="Email" type="text" class="input"></p>
<p><label class="label">Tlf</label>
<input name="Tlf" type="text" class="input"></p>
<p><label class="label">Adresse</label>
<input name="Adresse" type="text" class="input"></p>
<p><label class="label">Model</label>
<input name="Model" type="text" class="input"></p>
<p><label class="label">Mærke</label>
<input name="Mærke" type="text" class="input"></p>
<p><label class="label">PC_ID på solgt pc</label>
<input name="PC_ID" type="text" class="input"></p>
<p>
<button class="button" type="submit" value="Submit">Registrer</button></p>
</form>
这是RegOrdre.php文件中的代码。
<?php
$servername = "localhost";
$username = "root";
$password = "Passw0rd";
$dbname = "TEC";
$Navn = $_POST['Navn'];
$Email = $_POST['Email'];
$Tlf = $_POST['Tlf'];
$Adresse = $_POST['Adresse']
$Model = $_POST['Model']
$Maerke = $_POST['Mærke']
$PC_ID = $_POST['PC_ID']
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO Ordre (Navn, Email, Tlf, Adresse, Model, Maerke, PC_ID, Ansat)
VALUES ('".$Navn"', '".$Email"', '".$Tlf"', '".$Adresse"', '".$Model"', '".$Maerke"', '".$PC_ID"', 1)";
$conn->close();
?>