wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> |
| 2 | <?php |
| 3 | // (C) Copyright 2001 |
Wolfgang Denk | 2c9dfca | 2005-08-12 23:20:59 +0200 | [diff] [blame] | 4 | // Murray Jensen <Murray.Jensen@csiro.au> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | // CSIRO Manufacturing Science and Technology, Preston Lab |
| 6 | |
| 7 | // doedit page (hymod_bddb / boards) |
| 8 | |
| 9 | require("defs.php"); |
| 10 | |
| 11 | pg_head("$bddb_label - Add Log Entry Results"); |
| 12 | |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 13 | if (!isset($_REQUEST['serno']) || $_REQUEST['serno'] == '') |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 14 | die("serial number not specified!"); |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 15 | $serno=intval($_REQUEST['serno']); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 16 | |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 17 | if (isset($_REQUEST['logno'])) { |
| 18 | $logno=$_REQUEST['logno']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 19 | die("log number must not be set ($logno) when Creating!"); |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 20 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 21 | |
| 22 | $query="update log set serno=$serno"; |
| 23 | |
| 24 | list($y, $m, $d) = split("-", $date); |
| 25 | if (!checkdate($m, $d, $y) || $y < 1999) |
| 26 | die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); |
| 27 | $query.=", date='$date'"; |
| 28 | |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 29 | if (isset($_REQUEST['who'])) { |
| 30 | $who=$_REQUEST['who']; |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 31 | $query.=", who='" . $who . "'"; |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 32 | } |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 33 | |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 34 | if (isset($_REQUEST['details'])) { |
| 35 | $details=$_REQUEST['details']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 36 | $query.=", details='" . rawurlencode($details) . "'"; |
Wolfgang Denk | 804ecb1 | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 37 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 38 | |
| 39 | // echo "final query = '$query'<br>\n"; |
| 40 | |
| 41 | $sqlerr = ''; |
| 42 | |
| 43 | mysql_query("insert into log (logno) values (null)"); |
| 44 | if (mysql_errno()) |
| 45 | $sqlerr = mysql_error(); |
| 46 | else { |
| 47 | $logno = mysql_insert_id(); |
| 48 | if (!$logno) |
| 49 | $sqlerr = "couldn't allocate new serial number"; |
| 50 | else { |
| 51 | mysql_query($query . " where logno=$logno"); |
| 52 | if (mysql_errno()) |
| 53 | $sqlerr = mysql_error(); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if ($sqlerr == '') { |
| 58 | echo "<font size=+2>\n"; |
| 59 | echo "\t<p>\n"; |
| 60 | echo "\t\tA log entry with log number '$logno' was " . |
| 61 | "added to the board with serial number '$serno'\n"; |
| 62 | echo "\t</p>\n"; |
| 63 | echo "</font>\n"; |
| 64 | } |
| 65 | else { |
| 66 | echo "\t<font size=+4>\n"; |
| 67 | echo "\t\t<p>\n"; |
| 68 | echo "\t\t\tThe following SQL error was encountered:\n"; |
| 69 | echo "\t\t</p>\n"; |
| 70 | echo "\t\t<center>\n"; |
| 71 | printf("\t\t\t<b>%s</b>\n", $sqlerr); |
| 72 | echo "\t\t</center>\n"; |
| 73 | echo "\t</font>\n"; |
| 74 | } |
| 75 | |
| 76 | ?> |
| 77 | <p></p> |
| 78 | <table width="100%"> |
| 79 | <tr> |
| 80 | <td align=center><a href="brlog.php?serno=<?php echo "$serno"; ?>">Go to Browse</a></td> |
| 81 | <td align=center><a href="index.php">Back to Start</a></td> |
| 82 | </tr> |
| 83 | </table> |
| 84 | <?php |
| 85 | pg_foot(); |
| 86 | ?> |