-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequirements.php
More file actions
55 lines (45 loc) · 1.68 KB
/
requirements.php
File metadata and controls
55 lines (45 loc) · 1.68 KB
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
<?php
/*
duplicate of class.php, but with different variables. waste of code.
*/
include_once('parts/header.php');
require_once('parts/sqlCredentials.php');
if (!empty($_POST))
{
$connection = mysqli_connect($sqlHost, $sqlUser, $sqlPass, $sqlDB);
foreach($_POST as $key => $val)
$_POST[$key] = mysqli_real_escape_string($connection, $val);
mysqli_real_query($connection, sprintf("insert into requirements values('%s', '%s', '%s')", $_POST['major'], $_POST['type'], $_POST['courses'])) or die(mysqli_error($connection));
$connection->close();
}
$major = empty($_POST['major']) ? 'major' : $_POST['major'];
$type = empty($_POST['type']) ? 'type' : $_POST['type'];
$courses = empty($_POST['courses']) ? 'courses' : $_POST['courses'];
?>
<script type="text/javascript">
var mem = ['<?php echo $major; ?>',
'<?php echo $type; ?>',
'<?php echo $courses; ?>'
];
function fieldClear(id) {
if (document.getElementById('input'+id).value == mem[id])
document.getElementById('input'+id).value='';
}
function fieldPopulate(id)
{
if (document.getElementById('input'+id).value == '')
document.getElementById('input'+id).value = mem[id];
}
</script>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="text" onfocus="fieldClear(0)" onblur="fieldPopulate(0)" id="input0"
name="major" value="<?php echo $major; ?>">
<input type="text" onfocus="fieldClear(1)" onblur="fieldPopulate(1)" id="input1"
name="type" value="<?php echo $type; ?>">
<input type="text" onfocus="fieldClear(2)" onblur="fieldPopulate(2)" id="input2"
name="courses" value="<?php echo $courses; ?>">
<input type="submit" value="Insert into Requirement DB">
</form>
<?php
include_once('parts/footer.php');
?>