tan update in database

This commit is contained in:
Marcel Schwarz 2018-05-26 15:59:43 +02:00
parent c949aebc85
commit 57262adcb7
3 changed files with 49 additions and 3 deletions

View File

@ -1,12 +1,26 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<script src="js/newEntry.js"></script>
</head>
<body> <body>
Deine Tan ist: <form id="entry-form" action="php/addEntry.php" method="post">
Vorname:<br>
<?php echo $_GET["tan"]; ?> <input type="text" name="vorname"><br>
Nachname:<br>
<input type="text" name="nachname"><br>
E-Mail:<br>
<input type="text" name="email"><br>
Nachricht:<br>
<input type="text" name="eintrag"><br>
<input type="hidden" name="tan" value="<?php echo $_GET["tan"]?>"><br>
<input id="absenden" type="submit" value="Abschicken">
<button type="reset">Loeschen</button>
</form>
</body> </body>
</html> </html>

0
js/newEntry.js Normal file
View File

32
php/addEntry.php Normal file
View File

@ -0,0 +1,32 @@
<?php
consumeTan($_POST['tan']);
echo "Tan verbraucht " . $_POST['tan'];
function addEntry() {
}
function consumeTan($tan) {
//Stelle DB verbindung her
$user = 'root';
$password = 'root';
$db = 'friendsbook';
$host = 'localhost';
$port = 3306;
$database = new mysqli($host, $user, $password, $db, $port);
if ($database->connect_error) {
die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error);
}
$update = $database->query("UPDATE `tans` SET `used`= true WHERE `tan` = '" . $_POST['tan'] . "'");
}
?>