aboutsummaryrefslogtreecommitdiffstats
path: root/add.php
blob: 6ede522c8677fe1816008e7bfd66e796a224cf41 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta  http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<title></title>
</head>
<body>
<?php
//Debug
//echo 'Session: ' . session_id() . ' Count: ' . $_SESSION['counter'] . '<br>';
//var_dump($_SESSION);
?>
<br><fieldset>
<legend><span>Add Record</span></legend>
<br>
<?php
include('/home/kb0iic/config.inc');
if(isset($_POST['submit']))
{
	if(!empty($_POST['name']))
	{
		$seq=($_POST['seq']);
		$name=($_POST['name']);
		$version=($_POST['version']);
		$configure=($_POST['configure']);
		$build=($_POST['build']);
		$install=($_POST['install']);
		$setup=($_POST['setup']);
		$notes=($_POST['notes']);
		$url=($_POST['url']);

		//PKG TABLE
		$sqlpkg  = 'INSERT INTO PKG (id, seq, name, version) ';
		$sqlpkg .= 'VALUES (null, :seq, :name, :version);';

		//PKG_CFG TABLE
		$sqlcfg  = 'INSERT INTO PKG_CFG (pkg_id, configure) ';
		$sqlcfg .= 'VALUES (:pkg_id, :configure);';

		//PKG_BLD TABLE
		$sqlbld  = 'INSERT INTO PKG_BLD (pkg_id, build) ';
		$sqlbld .= 'VALUES (:pkg_id, :build);';

		//PKG_NST TABLE
		$sqlnst  = 'INSERT INTO PKG_NST (pkg_id, install) ';
		$sqlnst .= 'VALUES (:pkg_id, :install);';

		//PKG_SET TABLE
		$sqlset  = 'INSERT INTO PKG_SET (pkg_id, setup) ';
		$sqlset .= 'VALUES (:pkg_id, :setup);';

		//PKG_NOT TABLE
		$sqlnot  = 'INSERT INTO PKG_NOT (pkg_id, notes) ';
		$sqlnot .= 'VALUES (:pkg_id, :notes);';

		//PKG_URL TABLE
		$sqlurl  = 'INSERT INTO PKG_URL (pkg_id, url) ';
		$sqlurl .= 'VALUES (:pkg_id, :url);';

		try{
			$pdo->beginTransaction();
			$stmt = $pdo->prepare($sqlpkg);
			$stmt->execute(['seq' => $seq, 'name' => $name, 'version' => $version]);
			$pkgid = $pdo->lastInsertId();
			//echo "PKGID: '$pkgid' '$seq' '$name' '$version'";

			$stmt = $pdo->prepare($sqlcfg);
			$stmt->execute(['pkg_id' => $pkgid, 'configure' => $configure]);
			$stmt = $pdo->prepare($sqlbld);
			$stmt->execute(['pkg_id' => $pkgid, 'build' => $build]);
			$stmt = $pdo->prepare($sqlnst);
			$stmt->execute(['pkg_id' => $pkgid, 'install' => $install]);
			$stmt = $pdo->prepare($sqlset);
			$stmt->execute(['pkg_id' => $pkgid, 'setup' => $setup]);
			$stmt = $pdo->prepare($sqlnot);
			$stmt->execute(['pkg_id' => $pkgid, 'notes' => $notes]);
			$stmt = $pdo->prepare($sqlurl);
			$stmt->execute(['pkg_id' => $pkgid, 'url' => $url]);

			$pdo->commit();

		} catch(Exception $e) {
			$pdo->rollBack();
			throw $e;
		}

		header("location:list.php#$seq");

	} else {
		echo '<pre style="color:Red">';
		echo 'Need at least the following attributes: Sequence, Name';
		echo '</pre>';
	}
}
?>
<form method="post" action="">
<label for="seq">Sequence: </label>
<input type="text" name="seq" value="" id="seq"><br>
<label>Name: </label>
<input type="text" name="name" value="" id="name"><br>
<label>Version: </label>
<input type="text" name="version" value="" id="version"><br><br>
<label>Configure: </label>
<textarea name="configure" rows="2" cols="80"></textarea><br><br>
<label>Build: </label>
<textarea name="build" rows="2" cols="80"></textarea><br><br>
<label>Install: </label>
<textarea name="install" rows="2" cols="80"></textarea><br><br>
<label>Setup: </label>
<textarea name="setup" rows="2" cols="80"></textarea><br><br>
<label>Notes: </label>
<textarea name="notes" rows="2" cols="80"></textarea><br><br>
<label>Url: </label>
<textarea name="url" rows="2" cols="80"></textarea><br><br>
<br>
<br>
<input type="submit" name="submit" id="isub" value="Add">
</form>
</fieldset>
</body>
</html>