Chapter 31 Building a Shopping Cart



Download 1,54 Mb.
Pdf ko'rish
bet18/24
Sana28.03.2022
Hajmi1,54 Mb.
#514907
1   ...   14   15   16   17   18   19   20   21   ...   24
Bog'liq
9780321833891 ch31 WebEdition unsecured

Listing 31.14
 
purchase.php
—Script That Stores the Order Details in the Database and Gets the 
Payment Details 
include ('book_sc_fns.php'); 


Chapter 31 Building a Shopping Cart
31-23
// The shopping cart needs sessions, so start one 
session_start(); 
do_html_header("Checkout"); 
// create short variable names 
$name = $_POST['name']; 
$address = $_POST['address']; 
$city = $_POST['city']; 
$zip = $_POST['zip']; 
$country = $_POST['country']; 
// if filled out 
if (($_SESSION['cart']) && ($name) && ($address) && ($city)
&& ($zip) && ($country)) { 
// able to insert into database 
if(insert_order($_POST) != false ) { 
//display cart, not allowing changes and without pictures 
display_cart($_SESSION['cart'], false, 0); 
display_shipping(calculate_shipping_cost()); 
//get credit card details 
display_card_form($name); 
display_button("show_cart.php", "continue-shopping", "Continue Shopping"); 
} else { 
echo "
Could not store data, please try again.
"; 
display_button('checkout.php', 'back', 'Back'); 

} else { 
echo "
You did not fill in all the fields, please try again.

"; 
display_button('checkout.php', 'back', 'Back'); 

do_html_footer(); 
?> 
The logic here is straightforward: You check that the user filled out the form and inserted details into the 
database using a function called 
insert_order()
. This simple function pops the customer details into the 
database. The code for it is shown in Listing 31.15
Listing 31.15
 
insert_order()
 Function from 
order_fns.php
—Function That Inserts All the Details of 

Download 1,54 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   24




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish