Widen input element
[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, start='%s', stop='%s', task='%s', status=%d WHERE oid = %d",
31                      hour2min($_POST['time']),
32                      pg_escape_string($dbh, $_POST['start']),
33                      pg_escape_string($dbh, $_POST['stop']),
34                      pg_escape_string($dbh, $_POST['task']),
35                      $_POST['status'],
36                      $_POST['oid']);
37
38     $sth = pg_exec ($dbh, $query);
39     echo('<p><strong>Updated.</strong></p>');
40   }
41
42 ?>
43
44 <p>Return to <a href="index.php">Index</a>, <a href="edit.php?id=<?=$_POST['oid']?>">edit page</a></p>
45
46 </page>
47
48 # Local variables:
49 # mode: text
50 # mode: auto-fill
51 # end: