-
Notifications
You must be signed in to change notification settings - Fork 0
/
send-message.php
36 lines (34 loc) · 995 Bytes
/
send-message.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
<?php
// servername => localhost
// username =>
// password => empty
// database name => staff
$conn = mysqli_connect("localhost", "root", "", "vidhi chambers");
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$subject=$_REQUEST['subject'];
$message=$_REQUEST['Message'];
$sql = "INSERT INTO mess VALUES ('','$name',
'$email','$subject','$message')";
if(empty($name) || empty($email) || empty($message)){
echo "Please fill all the fields";
}
else if(mysqli_query($conn, $sql)){
echo "<script type='text/javascript'>
alert('Your message sent successfully');
window.history.go(-1);
</script>";
}
else{
echo "<script type='text/javascript'>
alert('Error connecting to the database');
window.history.go(-1);
</script>"
. mysqli_error($conn);
}
?>