Page 1 of 2
Shopping Cart
Posted: Mon Dec 22, 2008 4:06 pm
by asuperstar103
I am trying to learn how to use php. I know a lot about HTML, but have only been trying php out for about 6 months now. I have found the hardest thing with PHP is implementing my shopping cart. I am trying to install a php cart and I'm sure that I am making this way harder than it should be. I have so far been able to work with the view cart page and have it working just fine. My products are adding to the cart and appear correctly. My problem lies at checkout. I have a rough draft of my customer info. page and a continue button at the bottom of this page. The continue button is suppose to take my customers to the checkout.php page so they can input their shipping address and pmt. info. When I click on the continue button as it is now it simply does a sort of refresh and erases my input? Can anyone help? Not sure if I need to post my php code here or if it just gets viewed with the view source page. Here's a link to my customer.php page:
http://superflywatches.com/customer.php
If more info. is needed please do let me know. I am really frustrated because I thought this would be simple and it has now taken me more than two wks. to get this cart to work. I just don't know what else to check?

Re: Shopping Cart
Posted: Tue Dec 23, 2008 12:03 pm
by asuperstar103
Hmmm...did I do something wrong? I see others are viewing my post but not responding? Just wondering why and if I can do anything to get someone to offer assistance.

Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:02 pm
by Christopher
I don't think you asked a question...
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:14 pm
by asuperstar103
arborint wrote:I don't think you asked a question...
Hmmm...not sure if you read my first post?
I am trying to learn how to use php. I know a lot about HTML, but have only been trying php out for about 6 months now. I have found the hardest thing with PHP is implementing my shopping cart. I am trying to install a php cart and I'm sure that I am making this way harder than it should be. I have so far been able to work with the view cart page and have it working just fine. My products are adding to the cart and appear correctly. My problem lies at checkout. I have a rough draft of my customer info. page and a continue button at the bottom of this page. The continue button is suppose to take my customers to the checkout.php page so they can input their shipping address and pmt. info. When I click on the continue button as it is now it simply does a sort of refresh and erases my input? Can anyone help? Not sure if I need to post my php code here or if it just gets viewed with the view source page. Here's a link to my customer.php page:
http://superflywatches.com/customer.php
If more info. is needed please do let me know. I am really frustrated because I thought this would be simple and it has now taken me more than two wks. to get this cart to work. I just don't know what else to check?
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:18 pm
by TheBrandon
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:30 pm
by asuperstar103
It's this page I am having trouble with:
http://superflywatches.com/customer.php
When I click the continue button it takes me no where? I can not figure out what is wrong with my PHP code to cause this. If I posted my php code here would that help? Where would the problem lie - what page php code should I look at to figure out why that continue button will not take me to my checkout page?
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:31 pm
by Christopher
asuperstar103 wrote:Hmmm...not sure if you read my first post?
You didn't get any responses. I said that it was maybe because you did not ask a clear question. So you copy the original email again?!?
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:34 pm
by asuperstar103
arborint wrote:asuperstar103 wrote:Hmmm...not sure if you read my first post?
You didn't get any responses. I said that it was maybe because you did not ask a clear question. So you copy the original email again?!?
I'm not sure how much clearer I can be? What else should I offer so I can get some assistance here?
I posted this right above as well:
It's this page I am having trouble with:
http://superflywatches.com/customer.php
When I click the continue button it takes me no where? I can not figure out what is wrong with my PHP code to cause this. If I posted my php code here would that help? Where would the problem lie - what page php code should I look at to figure out why that continue button will not take me to my checkout page?
Hopefully that clears things up. Sorry.
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:35 pm
by TheBrandon
asuperstar103 wrote:
It's this page I am having trouble with:
http://superflywatches.com/customer.php
When I click the continue button it takes me no where? I can not figure out what is wrong with my PHP code to cause this. If I posted my php code here would that help? Where would the problem lie - what page php code should I look at to figure out why that continue button will not take me to my checkout page?
I'm guessing its your form, not your PHP, but I can't figure that out since I can't see the form.
You should post your files. Definitely the PHP processing file, and the form.
Re: Shopping Cart
Posted: Tue Dec 23, 2008 2:52 pm
by asuperstar103
Here is the code to my form that is initially giving me the probs.
Code: Select all
<?php session_start(); $itemcount = isset($_SESSION['itemcount']) ? $_SESSION['itemcount'] : 0; if ($itemcount == 0) { header("Location: "."error.php?msg=".rawurlencode("Please add items to your shopping cart before checking out.")); exit; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['email'])) { $_SESSION['firstname'] = $_POST['firstname']; $_SESSION['lastname'] = $_POST['lastname']; $_SESSION['address'] = $_POST['address']; $_SESSION['address2'] = $_POST['address2']; $_SESSION['city'] = $_POST['city']; $_SESSION['zip'] = $_POST['zip']; $_SESSION['state'] = $_POST['state']; $_SESSION['country'] = $_POST['country']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['fax'] = $_POST['fax']; if (ValidateEmail($_POST['email'])) { $_SESSION['email'] = $_POST['email']; header("Location: "."checkout.php"); } else { header("Location: "."error.php?msg=".rawurlencode("Invalid email address! Make sure you enter valid email address.")); } } } $firstname = isset($_SESSION['firstname']) ? $_SESSION['firstname'] : ''; $lastname = isset($_SESSION['lastname']) ? $_SESSION['lastname'] : ''; $email = isset($_SESSION['email']) ? $_SESSION['email'] : ''; $address = isset($_SESSION['address']) ? $_SESSION['address'] : ''; $address2 = isset($_SESSION['address2']) ? $_SESSION['address2'] : ''; $city = isset($_SESSION['city']) ? $_SESSION['city'] : ''; $zip = isset($_SESSION['zip']) ? $_SESSION['zip'] : ''; $state = isset($_SESSION['state']) ? $_SESSION['state'] : ''; $country = isset($_SESSION['country']) ? $_SESSION['country'] : ''; $phone = isset($_SESSION['phone']) ? $_SESSION['phone'] : ''; $fax = isset($_SESSION['fax']) ? $_SESSION['fax'] : ''; function ValidateEmail($email) { $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i'; return preg_match($pattern,$email); } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Customer Page</title>
<meta name="generator" content="WYSIWYG Web Builder - http://www.wysiwygwebbuilder.com">
</head>
<body bgcolor="#FFFFFF" text="#000000" style="background-repeat:no-repeat;scrollbar-face-color:#F0F0F0;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#F0F0F0;scrollbar-darkshadow-color:#696969;scrollbar-highlight-color:#FFFFFF;scrollbar-shadow-color:#A0A0A0;scrollbar-track-color:#C8C8C8;">
<div id="wb_Form1" style="position:absolute;left:34px;top:189px;width:428px;height:529px;z-index:21" align="left">
<form name="Form1" method="post" action="customer.php" id="Form1">
<div id="wb_Text1" style="position:absolute;left:143px;top:30px;width:202px;height:14px;z-index:0" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Please fill in the following information</font></div>
<div id="wb_Text2" style="position:absolute;left:17px;top:84px;width:150px;height:14px;z-index:1" align="left">
<font style="font-size:11px" color="#000000" face="Arial">First name</font></div>
<div id="wb_Text3" style="position:absolute;left:14px;top:111px;width:150px;height:14px;z-index:2" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Last name</font></div>
<div id="wb_Text4" style="position:absolute;left:20px;top:140px;width:150px;height:14px;z-index:3" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Email</font></div>
<div id="wb_Text5" style="position:absolute;left:17px;top:167px;width:150px;height:14px;z-index:4" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Address</font></div>
<div id="wb_Text6" style="position:absolute;left:15px;top:221px;width:150px;height:14px;z-index:5" align="left">
<font style="font-size:11px" color="#000000" face="Arial">City</font></div>
<div id="wb_Text7" style="position:absolute;left:14px;top:248px;width:150px;height:14px;z-index:6" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Zip Code</font></div>
<div id="wb_Text8" style="position:absolute;left:20px;top:277px;width:150px;height:14px;z-index:7" align="left">
<font style="font-size:11px" color="#000000" face="Arial">State</font></div>
<div id="wb_Text9" style="position:absolute;left:19px;top:304px;width:150px;height:14px;z-index:8" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Country</font></div>
<div id="wb_Text10" style="position:absolute;left:19px;top:331px;width:150px;height:14px;z-index:9" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Telephone</font></div>
<input type="text" id="Editbox1" style="position:absolute;left:113px;top:77px;width:90px;font-family:Courier New;font-size:16px;z-index:10" size="9" name="Editbox1" value="">
<input type="text" id="Editbox2" style="position:absolute;left:112px;top:106px;width:90px;font-family:Courier New;font-size:16px;z-index:11" size="9" name="Editbox2" value="">
<input type="text" id="Editbox3" style="position:absolute;left:114px;top:133px;width:90px;font-family:Courier New;font-size:16px;z-index:12" size="9" name="Editbox3" value="">
<input type="text" id="Editbox4" style="position:absolute;left:113px;top:161px;width:90px;font-family:Courier New;font-size:16px;z-index:13" size="9" name="Editbox4" value="">
<input type="text" id="Editbox5" style="position:absolute;left:115px;top:190px;width:90px;font-family:Courier New;font-size:16px;z-index:14" size="9" name="Editbox5" value="">
<input type="text" id="Editbox6" style="position:absolute;left:113px;top:217px;width:90px;font-family:Courier New;font-size:16px;z-index:15" size="9" name="Editbox6" value="">
<input type="text" id="Editbox7" style="position:absolute;left:113px;top:244px;width:90px;font-family:Courier New;font-size:16px;z-index:16" size="9" name="Editbox7" value="">
<input type="text" id="Editbox8" style="position:absolute;left:116px;top:272px;width:90px;font-family:Courier New;font-size:16px;z-index:17" size="9" name="Editbox8" value="">
<input type="text" id="Editbox9" style="position:absolute;left:114px;top:301px;width:90px;font-family:Courier New;font-size:16px;z-index:18" size="9" name="Editbox9" value="">
<input type="text" id="Editbox10" style="position:absolute;left:112px;top:328px;width:90px;font-family:Courier New;font-size:16px;z-index:19" size="9" name="Editbox10" value="">
<input type="submit" id="Button1" name="action" value="Continue" style="position:absolute;left:112px;top:438px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:20">
</form>
</div>
</body>
</html>
Not sure what the php processing file is? And thank you Brandon for your help - I only hope you can help me! IF I can just get this one flaw fixed I'll be on my way hopefully.
Re: Shopping Cart
Posted: Tue Dec 23, 2008 3:04 pm
by TheBrandon
Code: Select all
<form name="Form1" method="post" action="customer.php" id="Form1">
That is sending it back to the customer page.
When you click submit, it will execute the "action" command in the form, which in this case, is the same page you are already on.
A PHP processing file would normally be there. For example, you might have a form on contact-us.php and then submit.php to handle all the data/email functions.
But that is likely your first problem. Clicking submit is only sending you right back to the page you are on.
Re: Shopping Cart
Posted: Tue Dec 23, 2008 7:21 pm
by asuperstar103
OK so I changed this from customer.php to checkout.php - and it is taking me to my error page. If I changed that, is there something else I'm missing?
Re: Shopping Cart
Posted: Wed Dec 24, 2008 5:24 am
by jayshields
I think your next step should be to do something with your PHP code so that people can actually read it; line breaks and indentation would be a good start.
Re: Shopping Cart
Posted: Wed Dec 24, 2008 6:19 am
by asuperstar103
jayshields wrote:I think your next step should be to do something with your PHP code so that people can actually read it; line breaks and indentation would be a good start.
Yeah I have did that many times, I will do that again today. Wonder why when I cut and paste that code it does that. I even tried copying with formatting so that maybe it would hold the line breaks, nothing. Thanks.
Re: Shopping Cart
Posted: Wed Dec 24, 2008 12:06 pm
by asuperstar103
asuperstar103 wrote:jayshields wrote:I think your next step should be to do something with your PHP code so that people can actually read it; line breaks and indentation would be a good start.
Yeah I have did that many times, I will do that again today. Wonder why when I cut and paste that code it does that. I even tried copying with formatting so that maybe it would hold the line breaks, nothing. Thanks.
OK so I fixed all of my php code. Any idea why my customer page would be taking me to my error page instead of my checkout page. Or where I should look?