Ich versuche, in die Datenbank die Formulardaten einzufügen, aber es funktioniert nicht, ich habe den folgenden Code hinzugefügt. Bitte überprüfen Sie und informieren Sie mich, was das Problem ist. Da die Lösch- und Suchabfragen funktionieren, aber die Einfügung die einzige Abfrage ist, die nicht funktioniert. DankeDaten nicht in Datenbank einfügen
<form method="post" action= "assign5.php">
Name : <input type ="text" name="name" >
<br>
Flavor : <select name="flavor">
<option value="Chocolate">Chocolate</option>
<option value="Vanilla">Vanilla</option>
<option value="Strawberry">Strawberry</option>
<option value="MahngiVanilla">MahngiVanilla</option>
<option value="SastiStrawberry">SastiStrawberry</option>
</select>
<br>
Scoops:
<input type ="radio" name="scoops" value="1">1</input>
<input type ="radio" name="scoops" value="2">2</input>
<input type ="radio" name="scoops" value="3">3</input>
<input type ="radio" name="scoops" value="4">4</input>
<input type ="radio" name="scoops" value="5">5</input>
<input type ="submit" name="button" value="Place Order"/>
<br>
<br>
</form>
<?php
require_once 'login.php';
$connection = new mysqli($db_hostname,$db_username,$db_password,$db_database);
if($connection ->connect_error) die($connection ->connect_error);
if(isset($_POST['name']) && isset($_POST['Flavour']) && isset($_POST['Scoops'])){
$CName=$_POST['name'];
$Flavor=$_POST['flavor'];
$Scoops=$_POST['scoops'];
$sql ="INSERT INTO orders VALUES (CName, Flavour, Scoops) VALUES ('$CName', '$FLAVOUR', '$Scoops')";
$result=$connection->query($sql);
if(!$result) die($connection->error);
header("Location: assign5.php");
}
$connection->close();
?>
Umzug nach __prepared statements__ –
Die Variablen definiert sind in einem anderen Fall und Rechtschreibung als die in der SQL verwendet ~ '$ Flavor' und' $ FLAVOUR' – RamRaider