-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewform.php
More file actions
75 lines (62 loc) · 1.72 KB
/
newform.php
File metadata and controls
75 lines (62 loc) · 1.72 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
include_once('lib/head.php');
include_once('lib/include.php');
?>
<body>
<?php include_once('lib/navbar.php');?>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="well">
<form class="form-horizontal" action="newform.php" method="GET">
<fieldset)>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" for="Name">Name</label>
<div class="col-md-10">
<input id="name" name="name" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-2 control-label" for="form">Form</label>
<div class="col-md-10">
<textarea class="form-control" id="form" name="form" rows="20"></textarea>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-2 control-label" for="submit"></label>
<div class="col-md-10">
<button id="submit" name="submit" class="btn btn-success">Create</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<?php
if(isset($_GET['submit'])) {
newForm();
}
function newForm() {
$name = db_quote($_GET['name']);
$form = db_quote($_GET['form']);
/* Remove whitespaces */
$formshort = str_replace(' ', '', $name);
$result = db_query("INSERT INTO `forms` (`form-name`,`form`,`formshort`) VALUES (" . $name . "," . $form . "," . $formshort . ")");
if($result === false) {
$error = db_error();
// Handle failure - log the error, notify administrator, etc.
} else {
// We successfully inserted a row into the database
echo "<meta http-equiv=\"refresh\" content=\"0;URL=listforms.php\">";
}
}
?>
<!-- Page Content end here -->
</body>
</html>