-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmessage.php
More file actions
92 lines (83 loc) · 3.15 KB
/
message.php
File metadata and controls
92 lines (83 loc) · 3.15 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php /*
$conn = mysqli_connect("localhost", "kakashi", "Success01", "e-library") or die("Database Error");
$getMesg = mysqli_real_escape_string($conn, $_POST['text']);
$check_data = "SELECT replies FROM messages WHERE queries LIKE '%$getMesg%'";
$run_query = mysqli_query($conn, $check_data) or die("Error");
if(mysqli_num_rows($run_query) > 0){
$fetch_data = mysqli_fetch_assoc($run_query);
$replay = $fetch_data['replies'];
echo $replay;
}else{
echo "Sorry don't understand";
} */
include("include/header.php");
include("include/config.php");
?>
<div class="container">
<div class="container center">
<form method="POST" action="form.php" id="request-form">
<h3>Request A Book</h3>
<div class="input-field">
<i class="material-icons prefix">contacts</i>
<input type="text" name="name">
<label for="Name" class="name">Your Name</label>
</div>
<div class="input-field">
<i class="material-icons prefix">email</i>
<input type="email" name="email">
<label for="email" class="email">Your Email</label>
</div>
<div class="input-field">
<i class="material-icons prefix">book</i>
<input type="text" name="title"></input>
<label for="title" class="title">Book Title</label>
</div>
<div class="input-field">
<i class="material-icons prefix">contacts</i>
<input type="text" name="author"></input>
<label for="author" class="author">Book Author</label>
</div>
<button class="btn waves-effect waves-light blue-grey darken-1" type="submit" name="action">Submit
</button>
</form>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.13.1/validate.min.js"></script>
<script>
const constraints = {
name: {
presence: { allowEmpty: false }
},
email: {
presence: { allowEmpty: false },
email: true
},
title: {
presence: { allowEmpty: false }
},
author: {
presence: { allowEmpty: false }
}
};
const form = document.getElementById('request-form');
form.addEventListener('submit', function (event){
const formValues = {
name: form.elements.name.value,
email: form.elements.email.value,
title: form.elements.title.value,
author: form.elements.author.value
};
const errors = validate(formValues, constraints);
if (errors) {
event.preventDefault();
const errorMessage = Object
.values(errors)
.map(function (fieldValues) {return fieldValues.join(', ')})
.join("\n");
alert(errorMessage);
}
}, false);
</script>
<?php
include("include/footer.php");
?>