-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_contact.php
32 lines (23 loc) · 967 Bytes
/
update_contact.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
<?php
require_once 'login.php';
$connection = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if ($connection->connect_error) die($connection->connect_error);
if ( isset($_POST['contact_id']) &&
isset($_POST['first_name']) &&
isset($_POST['middle_name']) &&
isset($_POST['last_name']) &&
isset($_POST['update'])
)
{
$contact_id = $_POST['contact_id'];
$fname = $_POST['first_name'];
$mname = $_POST['middle_name'];
$lname = $_POST['last_name'];
$query = "INSERT INTO Contact (Fname, Mname, Lname) VALUES ('$fname', '$mname', '$lname')";
if($_POST['update'] == "true"){
$query = "UPDATE Contact SET Fname='$fname', Mname='$mname', Lname='$lname' WHERE Contact_id=$contact_id";
}
$result = $connection->query($query);
if (!$result) die ("Database access failed: " . $connection->error);
}
?>