-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.php
More file actions
59 lines (49 loc) · 1.9 KB
/
class.php
File metadata and controls
59 lines (49 loc) · 1.9 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
56
57
58
59
<?php
/*
duplicate of requirements.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 class values('%s', '%s', '%s', %d)", $_POST['name'], $_POST['title'], $_POST['link'], $_POST['credit'])) or die(mysqli_error($connection));
$connection->close();
}
$name = empty($_POST['name']) ? 'name' : $_POST['name'];
$title = empty($_POST['title']) ? 'title' : $_POST['title'];
$link = empty($_POST['link']) ? 'link' : $_POST['link'];
$credit = empty($_POST['credit']) ? 'credit' : $_POST['credit'];
?>
<script type="text/javascript">
var mem = ['<?php echo $name; ?>',
'<?php echo $title; ?>',
'<?php echo $link; ?>',
'<?php echo $credit; ?>'
];
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="name" value="<?php echo $name; ?>">
<input type="text" onfocus="fieldClear(1)" onblur="fieldPopulate(1)" id="input1"
name="title" value="<?php echo $title; ?>">
<input type="text" onfocus="fieldClear(2)" onblur="fieldPopulate(2)" id="input2"
name="link" value="<?php echo $link; ?>">
<input type="text" onfocus="fieldClear(3)" onblur="fieldPopulate(3)" id="input3"
name="credit" value="<?php echo $credit; ?>">
<input type="submit" value="Insert into Class DB">
</form>
<?php
include_once('parts/footer.php');
?>