-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.php
53 lines (47 loc) · 1.32 KB
/
add.php
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
<?php
include 'lib/DB.php';
include 'header.html';
include 'lib/Request.php';
if(isset($_POST['submitBtn']))
{
$db = new DB();
$name = Request::filtration($_POST['name']);
$lastname = Request::filtration($_POST['lastname']);
$userData = array(
'name' => $name,
'lastname' => $lastname
);
if($db->insert('users', $userData))
{
$msg = 'New user has been added';
}
else
{
$msg = 'Something went wrong';
}
}
?>
<div id="app">
<div class="msg success"><?php echo $msg;?></div>
<div id="formBlock">
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
<label for="name">Name: </label>
<input type="text" name="name" placeholder="Enter name" minlength="2" id="InptName" required><br\>
<label for="name">Last Name: </label>
<input type="text" name="lastname" placeholder="Enter lastname" minlength="2" id="InptLastName" required><br\>
<input type="submit" value="Add" name="submitBtn" id="btnSubmit">
</form>
</div>
</div>
<?php
include 'footer.html';
?>
<script>
$(function(){
var msg = "<?php echo $msg?>";
if(msg != '')
{
$('.msg').slideDown().delay(3000).slideUp();
}
});
</script>