Ich möchte, dass diese Werte in meine Datenbank aufgenommen werden, aber das geht einfach nicht.Warum werden meine Daten nicht in meine Datenbank aufgenommen?
Form Code
<form action='ryge.php' method='POST'>
<p> Navn: </p> <p><?php echo $_SESSION['first'] . " " . $_SESSION['last'] ?></p> <br>
<input type='text' name='name' placeholder='dit navn'> <br>
<input type='text' name='cig' placeholder='Navn på smøger'> <br>
<input type='text' name='brand' placeholder='Navn på brandet af smøger?'> <br>
<input type='text' name='unit' placeholder='Hvor mange enheder har du?'> <br>
<input type='text' name='pris' placeholder='Pris pr smøg'> <br>
<input type='text' name='lighter' placeholder='Har du lighter'> <br>
<input type='text' name='place' placeholder='Lokation til rhyyge'> <br>
<input type='text' name='tid' placeholder='Hvad tid passer dig bedst?'> <br>
<input type='text' name='howlong' placeholder='Hvor langtid har du at rhyyge i?'> <br>
<input type='text' name='day' placeholder='hvilke dag/dage'> <br>
<input type='text' name='pers' placeholder='Alene eller i gruppe?'> <br>
<button type='submit' name='tilføj' >Tilføj til dine præferencer broder</button>
</form>
PHP-Code
<?php
session_start();
include 'dbh.php';
$name = $_POST['name'];
$cig = $_POST['cig'];
$brand = $_POST['brand'];
$unit = $_POST['unit'];
$pris = $_POST['pris'];
$ligther = $_POST['ligther'];
$place = $_POST['place'];
$tid = $_POST['tid'];
$howlong = $_POST['howlong'];
$day = $_POST['day'];
$pers = $_POST['pers'];
$sql = "INSERT INTO prod (name, cig, brand, unit, pris, lighter, place, tid, howlong, day, pers)
VALUES ('$name', '$cig', '$brand', '$unit', '$pris', '$ligther', '$place', '$tid', '$howling', '$day', '$pers')";
$result = mysqli_query($conn, $sql);
header("Location: index.php");
Von wo Sie bekommen '$ _POST [ 'name']' und '$ _POST [ 'tid']' Werte? –
Sie sagen, es funktioniert nicht, aber haben Sie einen Fehler, Warnung? Beachten Sie, dass Sie 'dbh.php' zweimal einschließen. – AnthonyB
ich bekomme keine Fehlermeldung, und mit den $ _POST ['name'] und $ _POST ['tid'] habe ich es jetzt korrigiert, immer noch nicht funktioniert – WilliamDelphi