aboutsummaryrefslogtreecommitdiff
path: root/www/update.php
blob: 26c05caa1d6df4d298cd97e22fe867ccd3b79e0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

function update_db($db){

	$id = SQLite3::escapeString(htmlentities($_POST["id"]));
	$name = SQLite3::escapeString(htmlentities($_POST["name"]));
	$adresse = SQLite3::escapeString(htmlentities($_POST["adresse"]));
	$telefonnummer = SQLite3::escapeString(htmlentities($_POST["telefonnummer"]));
	$handynummer = SQLite3::escapeString(htmlentities($_POST["handynummer"]));
	$email = SQLite3::escapeString(htmlentities($_POST["email"]));
	$bday = SQLite3::escapeString(htmlentities($_POST["geburtstag"]));

	if((!empty($id) && !preg_match("/^[0-9]+$/", $id)) || (!empty($telefonnummer) && !preg_match("/^[0-9]+$/", $telefonnummer) )|| (!empty($email) && !preg_match("/^.+@.+$/", $email))){
		return false;
	}

	if($db->exec("
		BEGIN TRANSACTION;
		UPDATE jg SET name='".$name."', adresse='".$adresse."', telefonnummer='".$telefonnummer."', handynummer='".$handynummer."', email='".$email."', geburtstag='".$bday."' WHERE id=".$id.";
		COMMIT;
	")){
		return true;
	} else {
		return false;
	}
}