-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
38 lines (34 loc) · 1.15 KB
/
Copy pathinsert.php
File metadata and controls
38 lines (34 loc) · 1.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
<?php
include_once('connect.php');
?>
<?php
//echo 'HI';
$db_handle = mysql_connect($server, $username, $password) or die('Error : ' . mysql_error());
$db_found = mysql_select_db($database, $db_handle) or die('Error : ' . mysql_error());
$response_array = array();
if ($db_found){
if (empty($_POST['name'])){
$response_array['status'] = 'error';
$response_array['message'] = 'Name is Blank';
}elseif(empty($_POST['email'])){
$response_array['status'] = 'error';
$response_array['message'] = 'Email is blank or invalid';
}elseif(empty($_POST['msg'])){
$response_array['status'] = 'error';
$response_array['message'] = 'Message is empty';
}else{
$query = "INSERT INTO wishdata (name, email, msg) VALUES ('". $_POST['name'] ."', '". $_POST['email'] ."', '". $_POST['msg'] ."')";
$results = mysql_query($query);
//echo ' as : ' . $query . ' ';
if ($results == 1){
$response_array['status'] = 'success';
$response_array['message'] = 'Wish Inserted';
}
mysql_close($link);
}
}else{
$response_array['message'] = 'Not Found';
}
//header('Content-type: application/json');
echo json_encode($response_array);
?>