diedVIPs

html knowhow

Daten in CSV-Datei speichern










Daten in CSV-Datei speichern

So sieht´s aus



   

Bitte alle mit markierten Felder ausfüllen.

Hans Busch Heppenheim von Kronberg Str. 1 ham.busch@web.de 14.04.1953 062523054299 Super
Karin Lieberwirth Heppenheim von Kronberg Str. 1 kaliber@web.de 04.12.1954 062523054299 Super
Hans Busch Heppenheim von Kronberg Str. 1 ham.busch@web.de 03.08.2021 062523054299 Super
Hans Busch Heppenheim von Kronberg Str. 1 ham.busch@web.de 03.08.2021 062523054299 Super
Hans Busch Heppenheim von Kronberg Str. 1 ham.busch@web.de 03.08.2021 062523054299 Super
Hans Busch Heppenheim Von-Kronberg-Str. Ham.busch@web.de 28.08.2021 062523054299 Gut
Hans Busch Heppenheim Von-Kronberg-Str. Ham.busch@web.de 05.08.2021 062523054299 Super
Hans Busch heppenheim von Kronberg Str. 1 ham.busch@web.de 06.04.2022 Super
Hans Busch heppenheim von Kronberg Str. 1 ham.busch@web.de 06.04.2022 Super
Hans Busch Heppenheim 1 Von-Kronberg-Str. Ham.busch@web.de 15.04.2022 062523054299 Super
Hans Busch Heppenheim Von-Kronberg-Str. Ham.busch@web.de 03.02.2023 062523054299 Gut
Hans Busch Heppenheim Von-Kronberg-Str. Ham.busch@web.de 03.02.2023 062523054299 Super
Quellcode
<html>
<head>

<style type="text/css">
form {width: 500px; padding: 10px; margin: Auto;}
span.pflichtfeld {font-size: 0.90rem; color: Red;}
blockquote {width: 475px; margin: Auto;}
input[type=text], input[type=password], input[type=search], input[type=number], input[type=email], input[type=date], input[type=time], input[type=checkbox], input[type=submit], input[type=reset], button[type=button], button[type=submit], textarea, select {
border: Solid 1px #9A9A9A; font-family: Verdana, Arial, Sans-Serif; font-size: 0.95rem; transition: box-shadow 0.3s;}
input[type=text]:focus, input[type=password]:focus, input[type=search]:focus, input[type=number]:focus, input[type=email]:focus, input[type=date]:focus, input[type=time]:focus, input[type=submit]:focus, input[type=reset]:focus, input[type=checkbox]:focus, button[type=button]:focus, button[type=submit]:focus, textarea:focus, select:focus {
border:0; outline:0; /* Chromium */ border: Solid 1px rgb(34,132,230); box-shadow: 0px 0px 3px 0px rgb(34,132,230);}
input[type=button], input[type=submit], input[type=reset], button[type=button], button[type=reset] {
border: Solid 1px #9A9A9A; background-color: #E1E1E1; font-size: 0.95rem; transition: background-color 0.4s;}
input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover, button[type=button]:hover, button[type=reset]:hover {
border: Solid 1px #0078D7; background-color: #E5F1FB;}
input[type=checkbox]:checked + label, input[type=radio]:checked + label {color: rgb(34,132,230);}
label:hover {color: rgb(34,132,230);}
option:nth-child(even) {background-color: #E5F1FB; }
.csvTable{font-size: 0.7em;border-top: 1px solid #ccc;border-left: 1px solid #ccc;border-right: 1px solid #ccc;color: black;}
.csvTable th{text-align:left;border-bottom: 1px solid #ccc;}
.csvTable td{border-bottom: 1px solid #ccc;}

</style
<head>

<body >
<?php
error_reporting(1); // (0/1)
$name = isset($_POST["name"]) ? trim($_POST["name"]) : ""; // Ihr Name
$wohnort = isset($_POST["wohnort"]) ? trim($_POST["wohnort"]) : ""; // Wohnort
$strasse = isset($_POST["strasse"]) ? trim($_POST["strasse"]) : ""; // Straße
$email = isset($_POST["email"]) ? trim($_POST["email"]) : ""; // E-Mail
$geburtsdatum = isset($_POST["geburtsdatum"]) ? $_POST["geburtsdatum"] : date("Y-m-d"); // Geburtsdatum
$mobiltelefon = isset($_POST["mobiltelefon"]) ? trim($_POST["mobiltelefon"]) : ""; // Mobiltelefon
$telefon = isset($_POST["telefon"]) ? trim($_POST["telefon"]) : ""; // Telefon
$gefaellt_mir = isset($_POST["gefaellt_mir"]) ? $_POST["gefaellt_mir"] : ""; // Gefällt mir

// Auswahlliste: Gefällt mir
$array = [
"Super",
"Gut",
"Geht so",
"Is nix",
];
$gefaellt_mirAW = "<select name='gefaellt_mir' size='1' required='required' id='aw7' tabindex='8'>";
foreach ($array as $value) {
$gefaellt_mirAW .= "\n <option value='" . $value . "'" .
((isset($_POST["gefaellt_mir"]) ? $_POST["gefaellt_mir"] : "") == $value ?
" selected='selected'" : "") . ">" . $value . "</option>";
}
$gefaellt_mirAW .= "\n </select>";


// Benutzereingaben überprüfen
// Die Meldungen müssen hier eventuell angepasst werden.
$Fehler = ["name"=>"", "wohnort"=>"", "strasse"=>"", "email"=>"", "geburtsdatum"=>"",
"gefaellt_mir"=>""];
if (isset($_POST["abschicken_x"])) {
$Fehler["name"] = strlen($_POST["name"]) < 10 ? " Bitte füllen Sie dieses Feld aus (min. 5 Zeichen)!" : "";
$Fehler["name"] .= strlen($_POST["name"]) > 30 ? " Es sind maximal 30 Zeichen erlaubt!" : "";
$Fehler["wohnort"] = strlen($_POST["wohnort"]) < 10 ? " Bitte füllen Sie dieses Feld aus (min. 10 Zeichen)!" : "";
$Fehler["wohnort"] .= strlen($_POST["wohnort"]) > 30 ? " Es sind maximal 30 Zeichen erlaubt!" : "";
$Fehler["strasse"] = strlen($_POST["strasse"]) < 10 ? " Bitte füllen Sie dieses Feld aus (min. 10 Zeichen)!" : "";
$Fehler["strasse"] .= strlen($_POST["strasse"]) > 30 ? " Es sind maximal 30 Zeichen erlaubt!" : "";
$Fehler["email"] = strlen($_POST["email"]) < 10 ? " Bitte füllen Sie dieses Feld aus (min. 10 Zeichen)!" : "";
$Fehler["email"] .= strlen($_POST["email"]) > 30 ? " Es sind maximal 32 Zeichen erlaubt!" : "";
$Fehler["geburtsdatum"] = strlen($_POST["geburtsdatum"]) < 10 ? " Bitte füllen Sie dieses Feld aus (min. 10 Zeichen)!" : "";
$Fehler["geburtsdatum"] .= strlen($_POST["geburtsdatum"]) > 30 ? " Es sind maximal 30 Zeichen erlaubt!" : "";
$Fehler["gefaellt_mir"] = $gefaellt_mir == "" ? " Bitte wählen Sie einen Eintrag aus!" : "";
}
$Formular = "
<form action='" . $_SERVER["SCRIPT_NAME"] . "' method='post'>
<p>
<label> Ihr Name:
<span class='pflichtfeld'>&#10034; " . $Fehler["name"] . "</span><br>
<input type='text' name='name' value='" . $name . "' size='30' maxlength='30' required='required' tabindex='1'>
</label>
</p>
<p>
<label> Wohnort:
<span class='pflichtfeld'>&#10034; " . $Fehler["wohnort"] . "</span><br>
<input type='text' name='wohnort' value='" . $wohnort . "' size='30' maxlength='30' required='required' tabindex='2'>
</label>
</p>
<p>
<label> Straße:
<span class='pflichtfeld'>&#10034; " . $Fehler["strasse"] . "</span><br>
<input type='text' name='strasse' value='" . $strasse . "' size='30' maxlength='30' required='required' tabindex='3'>
</label>
</p>
<p>
<label> E-Mail:
<span class='pflichtfeld'>&#10034; " . $Fehler["email"] . "</span><br>
<input type='email' name='email' value='" . $email . "' size='30' maxlength='32' required='required' tabindex='4'>
</label>
</p>
<p>
<label> Geburtsdatum:
<span class='pflichtfeld'>&#10034; " . $Fehler["geburtsdatum"] . "</span><br>
<input type='date' name='geburtsdatum' value='" . $geburtsdatum . "' size='30' maxlength='30' required='required' tabindex='5'>
</label>
</p>
<p>
<label> Mobiltelefon:
<br>
<input type='tel' name='mobiltelefon' value='" . $mobiltelefon . "' size='30' maxlength='30' tabindex='6'>
</label>
</p>
<p>
<label> Telefon:
<br>
<input type='tel' name='telefon' value='" . $telefon . "' size='30' tabindex='7'>
</label>
</p>
<p>
<label for='aw7'>Gefällt mir:</label>
<span class='pflichtfeld'>&#10034; " . $Fehler["gefaellt_mir"] . "</span><br>
" . $gefaellt_mirAW . "
</p>
<p>
<br>
<input type='image' src='../Bilder/vorschau.png' name='vorschau' title='Vorschau zeigen'> &nbsp;
<input type='image' src='../Bilder/abbrechen.png' border='0' title='Formular abbrechen' formaction='" . $_SERVER["SCRIPT_NAME"] . "'> &nbsp;
<input type='image' src='../Bilder/absenden.png' name='abschicken' title='Formular absenden' tabindex='9'>
</p>
<p>
<small>Bitte alle mit <span class='pflichtfeld'>&#10034;</span>
markierten Felder ausfüllen.</small>
</p>
</form>
";

// Vorschau
if (isset($_POST["vorschau_y"])) {
echo strip_tags("<blockquote>
<h4>Vorschau</h4>
<b>Ihr Name:</b> $name <br>
<b>Wohnort:</b> $wohnort <br>
<b>Straße:</b> $strasse <br>
<b>E-Mail:</b> $email <br>
<b>Geburtsdatum:</b> $geburtsdatum <br>
<b>Mobiltelefon:</b> $mobiltelefon <br>
<b>Telefon:</b> $telefon <br>
<b>Gefällt mir:</b> $gefaellt_mir
</blockquote>", "<blockquote><h4><b><br>");
}
if (isset($_POST["abschicken_x"])) {
if (implode("", $Fehler) == "") {
if (substr_count($geburtsdatum, "-") == 2) {
list($jahr, $monat, $tag) = explode("-", $geburtsdatum);
if (strlen($jahr) == 4) {
$geburtsdatum = "$tag.$monat.$jahr";
}
}
$Datei = "../Extra/formdatei.csv";
$name = str_replace([";", "\r", "\n"], "", $name);
$wohnort = str_replace([";", "\r", "\n"], "", $wohnort);
$strasse = str_replace([";", "\r", "\n"], "", $strasse);
$email = str_replace([";", "\r", "\n"], "", $email);
$geburtsdatum = str_replace([";", "\r", "\n"], "", $geburtsdatum);
$mobiltelefon = str_replace([";", "\r", "\n"], "", $mobiltelefon);
$telefon = str_replace([";", "\r", "\n"], "", $telefon);
$gefaellt_mir = str_replace([";", "\r", "\n"], "", $gefaellt_mir);
$Text = "$name;$wohnort;$strasse;$email;$geburtsdatum;$mobiltelefon;$telefon;$gefaellt_mir;\n";
$Fh = fopen($Datei, "a+");
if (fwrite($Fh, $Text)) {
echo "<p>Die Daten wurden eingetragen und die Liste sieht nun so aus:</p>";
}
else {
echo "<p>Fehler beim eintragen der Daten!</p>";
}
fclose($Fh);
}
else {
echo "<p><span class='pflichtfeld'><strong>Eingabefehler, Bitte korrigieren</strong></span></p>";
echo $Formular;
}
}
else {
echo $Formular;
}
?>

<?php
$hasTitle = true;
echo '<table border="0" align="center" cellspacing="0" cellpadding="5" width="90%" class="csvTable">';
$handle = fopen("../Extra/formdatei.csv", "r");
$start = 0;
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE)
{
echo '<tr>' . "\n";
for ( $x = 0; $x < count($data); $x++)
{
if ($start == 0 && $hasTitle == true)
echo '<th>'.$data[$x].'</th>' . "\n";
else
echo '<td>'.$data[$x].'</td>' . "\n";
}
$start++;
echo '</tr>' . "\n";
}
fclose($handle);
echo '</table>';
?>


</body>
</html>











Kontakt    Datenschutz   Impressum