forked from ronilcajan/point-of-sale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_customer.php
executable file
·21 lines (20 loc) · 1 KB
/
add_customer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
include('server/connection.php');
if(isset($_POST['submit'])){
$user = mysqli_real_escape_string($db, $_POST['user']);
$fname = mysqli_real_escape_string($db, $_POST['fname']);
$lname = mysqli_real_escape_string($db, $_POST['lname']);
$address = mysqli_real_escape_string($db, $_POST['address']);
$number = mysqli_real_escape_string($db, $_POST['number']);
$image = $_FILES['image']['name'];
$target = "images/".basename($_FILES['image']['name']);
$sql = "INSERT INTO customer (firstname,lastname,address,contact_number,image) VALUES ('$fname','$lname','$address','$number','$image')";
$result = mysqli_query($db, $sql);
if(move_uploaded_file($_FILES['image']['tmp_name'], $target) && $result == true){
$query = "INSERT INTO logs (username,purpose,logs_time) VALUES('$user','Customer $fname Added',CURRENT_TIMESTAMP)";
$insert = mysqli_query($db,$query);
header('location: main.php?username='.$user.'&added');
}else{
$msg = "Something went wrong!";
}
}