d26e267b1955bdc83249662d8959b9c969cd9652
[infodrom.org/service.infodrom.org] / src / InfoCon / stempel / update.wml
1 <?
2   if (!isset($_POST['oid'])) {
3     header('Location: index.php');
4     exit(0);
5   }
6 ?>
7 #include <infocon.style>
8
9 <page func=InfoCon title="Stempeluhr">
10
11 <?
12   function hour2min($hour)
13   {
14     $parts = explode(':', $hour);
15
16     return $parts[0]*60 + $parts[1];
17   }
18
19   $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
20          or die("Unable to connect to SQL server");
21
22
23   if (isset($_POST['delete'])) {
24     $query = sprintf("DELETE FROM stempel WHERE oid = %d",
25                      $_POST['oid']);
26
27     $sth = pg_exec ($dbh, $query);
28     echo('<p><strong>Deleted.</strong></p>');
29   } else {
30     $query = sprintf("UPDATE stempel SET time=%d, task='%s', status=%d WHERE oid = %d",
31                      hour2min($_POST['time']),
32                      pg_escape_string($dbh, $_POST['task']),
33                      $_POST['status'],
34                      $_POST['oid']);
35
36     $sth = pg_exec ($dbh, $query);
37     echo('<p><strong>Updated.</strong></p>');
38   }
39
40 ?>
41
42 <p>Return to <a href="index.php">Index</a>, <a href="edit.php?id=<?=$_POST['oid']?>">edit page</a></p>
43
44 </page>
45
46 # Local variables:
47 # mode: text
48 # mode: auto-fill
49 # end: