-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.php
47 lines (34 loc) · 988 Bytes
/
messages.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
<?php
require_once('dbconfig.php');
if(isset($_POST['submit'])){
$conn = new mysqli(HOST,USERNAME,PASSWORD,DBNAME);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "insert into messages(name,email,content) values(?,?,?);";
$name = $_POST['emri'];
$email = $_POST['email'];
$content = $_POST['content'];
$statement = $conn->prepare($query);
$statement->bind_param("sss",$name,$email,$content);
$statement->execute();
$rows = $statement->affected_rows;
if($rows==1){
echo '<script type="text/javascript">';
echo 'alert("Message has been sent!")';
echo '</script>';
}
else{
echo '<script type="text/javascript">';
echo 'alert("Message has not sent! ")';
echo '</script>';
}
$statement->close();
$conn->close();
}
?>
<html>
<body>
<a href="index.html">Go Back</a>
</body>
</html>