-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.php
84 lines (70 loc) · 2.12 KB
/
checkout.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
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once 'utilities.php';
require_once 'header.php';
require_once 'login.php';
require_once 'customer_functions.php';
$_GET = array_map( 'mysql_real_escape_string', $_GET );
$_POST = array_map( 'mysql_real_escape_string', $_POST );
if( isLoggedIn() && $_POST['CO'] )
{
displayShippingInfo( $_POST['order_id'] );
}
else if( isLoggedIn() && $_POST['ship_submit'] )
{
if( !$_POST['last_name'] )
{
renderError( "You must enter a last name." );
$my_error++;
}
if( !$_POST['first_name'] )
{
renderError( "You must enter a first name." );
$my_error++;
}
if( strlen( $_POST['middle_initial'] ) > 1 )
{
renderError( "You may not have more than one letter for middle initial" );
$my_error++;
}
if( !validateZipCode( $_POST['zip_code'] ) )
{
renderError("error");
$my_error++;
}
if( !$_POST['street_address'] )
{
renderError("error2");
$my_error++;
}
if( !$_POST['city'] )
{
renderError( "error3" );
$my_error++;
}
if( $my_error < 1 )
{
$query = "UPDATE orders
SET shipping_first_name='".$_POST['first_name']."',
shipping_last_name='".$_POST['last_name']."',
shipping_middle_initial='".$_POST['middle_initial']."',
shipping_address='".$_POST['street_address']."',
shipping_city='".$_POST['city']."', shipping_state='".$_POST['state']."' ,
shipping_zip_code='".$_POST['zip_code']."', shippinginfo_id='".$_POST['OC_ship']."', placed_date=NOW()
WHERE id=".$_POST['order_id']." LIMIT 1";
$result = mysqlQuery( $query );
if( !$result || mysql_affected_rows() > 1 )
{
renderError("UPDATE FAILED");
}
else
{
echo "UPDATE SUCCESS!!!<br/>";
}
}
else
{
displayShippingInfoFromPOST( $_POST['order_id'] );
}
}
require_once 'footer.php';
?>