Moin Moin, bin grade dabei ein Script zu schreiben, wo Fahrzeuge geloggt werden, wer welches Fahrzeug genutzt hat
leider wird das nicht in der Datenbank eintragen
wäre cool wenn jemand mir mal kurz erklären könnte wo der fehler liegt.
leider wird das nicht in der Datenbank eintragen
PHP-Code:
<?php
/**
* @author
* @copyright 2023
*/
echo '<style>*{
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
body{
font-family: Helvetica;
-webkit-font-smoothing: antialiased;
background: rgba( 71, 147, 227, 1);
}
h2{
text-align: center;
font-size: 18px;
text-transform: uppercase;
letter-spacing: 1px;
color: white;
padding: 30px 0;
}
/* Table Styles */
.table-wrapper{
margin: 10px 70px 70px;
box-shadow: 0px 35px 50px rgba( 0, 0, 0, 0.2 );
}
.fl-table {
border-radius: 5px;
font-size: 12px;
font-weight: normal;
border: none;
border-collapse: collapse;
width: 100%;
max-width: 100%;
white-space: nowrap;
background-color: white;
}
.fl-table td, .fl-table th {
text-align: center;
padding: 8px;
}
.fl-table td {
border-right: 1px solid #f8f8f8;
font-size: 12px;
}
.fl-table thead th {
color: #ffffff;
background: #4FC3A1;
}
.fl-table thead th:nth-child(odd) {
color: #ffffff;
background: #324960;
}
.fl-table tr:nth-child(even) {
background: #F8F8F8;
}
/* Responsive */
@media (max-width: 767px) {
.fl-table {
display: block;
width: 100%;
}
.table-wrapper:before{
content: "Scroll horizontally >";
display: block;
text-align: right;
font-size: 11px;
color: white;
padding: 0 0 10px;
}
.fl-table thead, .fl-table tbody, .fl-table thead th {
display: block;
}
.fl-table thead th:last-child{
border-bottom: none;
}
.fl-table thead {
float: left;
}
.fl-table tbody {
width: auto;
position: relative;
overflow-x: auto;
}
.fl-table td, .fl-table th {
padding: 20px .625em .625em .625em;
height: 60px;
vertical-align: middle;
box-sizing: border-box;
overflow-x: hidden;
overflow-y: auto;
width: 120px;
font-size: 13px;
text-overflow: ellipsis;
}
.fl-table thead th {
text-align: left;
border-bottom: 1px solid #f7f7f9;
}
.fl-table tbody tr {
display: table-cell;
}
.fl-table tbody tr:nth-child(odd) {
background: none;
}
.fl-table tr:nth-child(even) {
background: transparent;
}
.fl-table tr td:nth-child(odd) {
background: #F8F8F8;
border-right: 1px solid #E6E4E4;
}
.fl-table tr td:nth-child(even) {
border-right: 1px solid #E6E4E4;
}
.fl-table tbody td {
display: block;
text-align: center;
}
}</style>';
error_reporting(E_ALL);
$db = mysqli_connect("localhost", "car", "x!", "x");
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
else {
$timestamp = time();
$datum = date("d.m.Y - H:i", $timestamp);
if (isset($_POST['aktion']) and $_POST['aktion']=='speichern') {
$name = $_POST['vorname'];
$auto = $_POST['fahrzeug'];
$anmerkung = $_POST['anmerkung'];
$eintrag = "INSERT INTO miru_car (name, auto, zeit, anmerkung) VALUES ('$name', '$auto', '$datum', '$anmerkung')";
mysqli_query($db, $eintrag);
echo "Daten wurden gespeichert";
} else
{
echo '<form action="" method="post">
<table class="fl-table">
<tr>
<td>Name</td>
<td>Fahrzeug</td>
<td>Anmerkung</td>
<td>Erstellt</td>
</tr>
<tr>
<td> <input type="text" id="name" name="name"></td>
<td><input type="text" id="auto" name="auto"></td>
<td><input type="text" id="anmerkung" name="anmerkung"></td>
<td>< <input type="hidden" name="zeit" value="'.$datum.'">'.$datum.'</td>
<input type="hidden" name="aktion" value="speichern">
<td> <input type="submit" value="Senden"></td>
</tr>
</table>
</form>';
}
echo '<center><h1>Auto Logbuch</h1></center>';
echo '<div class="table-wrapper">
<table class="fl-table">
<tr>
<td><strong>Eintrag</strong></td>
<td><strong>Name</strong></td>
<td><strong>Auto</strong></td>
<td><strong>Anmerkung</strong></td>
</tr>';
$ergebnis = mysqli_query($db, "SELECT * FROM `miru_car`;");
while($row = mysqli_fetch_object($ergebnis))
{
echo '
<tr>
<strong><td>'.$row->id.'</td></strong>
<strong><td>'.$row->vorname.'</td>
<td>'.$row->fahrzeug.'</td>
<td>'.$row->erstellt.'</td></strong>
';
}
echo'</tr>
</table>
</div>';
}
?>
Kommentar