-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathphp_send.php
More file actions
44 lines (27 loc) · 969 Bytes
/
php_send.php
File metadata and controls
44 lines (27 loc) · 969 Bytes
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Neptune";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
$conn->set_charset("utf8");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "INSERT INTO Expenses (amount , type , category , recipient , date)
VALUES ('$_POST[amount]' , '$_POST[type]' , '$_POST[category]' ,'$_POST[recipient]' , '$_POST[date]')";
if (mysqli_query($conn, $sql)) {
if (empty($_POST['amount']) || empty($_POST['type']) || empty($_POST['category']) || empty($_POST['recipient']) || empty($_POST['date']) ) {
header("location: insert.php?error=emptyfields&status=&data=");
exit();
}
else{
header("location:insert.php?status=success&data=");
}
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>