-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateCustomer.php
72 lines (52 loc) · 2.54 KB
/
updateCustomer.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
include('../ado519/adodb5/adodb.inc.php');
include('../cosc3339/connect.php');
include('../cosc3339/updateCustomer.html');
session_start();
$username = $_SESSION['username'];
$newUser = $username;
if (isset($username) && isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['location'])
&& isset($_POST['petType']) && isset($_POST['age']) && isset($_POST['about']) ){
$username = $_SESSION['$username'];
updateCustomer($connection, $newUser);
}
function updateCustomer($connection, $newUser ){
$username = $_SESSION['username'];
$newUser = $username;
// Open a connection to the database
//
$db = ADONewConnection('mysql'); // Create a connection handle to the local database
$db->PConnect('localhost', // Host to connect to
'aalibrac', // Database user name
'yR6160svXv', // Password
'aalibrac_sitterRus'); // Database
// If the values are posted, insert them into the database.
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$location = $_POST['location'];
$petType = $_POST['petType'];
$age = $_POST['age'];
$about = $_POST['about'];
$query = "UPDATE Customer SET Customer_Fname = '".$fname ."' where Customer_username = '" .$newUser . "' ";
$result = mysqli_query($connection, $query);
$query = "UPDATE Customer SET Customer_Lname = '".$lname ."' where Customer_username = '" .$newUser . "'";
$result = mysqli_query($connection, $query);
$query = "UPDATE Customer SET Customer_location = '".$location ."' where Customer_username = '" .$newUser . "'";
$result = mysqli_query($connection, $query);
$query = "UPDATE Customer SET Customer_petType = '".$petType ."' where Customer_username = '" .$newUser . "'";
$result = mysqli_query($connection, $query);
$query = "UPDATE Customer SET Customer_age = '".$age ."' where Customer_username = '" .$newUser . "'";
$result = mysqli_query($connection, $query);
$query = "UPDATE Customer SET Customer_about = '".$about ."' where Customer_username = '" .$newUser . "'";
$result = mysqli_query($connection, $query);
if($result){
$smsg = "Updated Successfully.";
print $smsg;
echo "<script> window.location.assign('customerHomepage.php'); </script>";
}
else{
$fmsg ="User UPDATE Failed";
print $fmsg;
}
}
?>