Help with Checkout Page...
Hi all,
I need to write up a simple checkout page in php. But this will need to be 'connected' in a 'variable sense' with photo-graffix gallery.
I have some code but very little, that's why I am here for some help.Ok, first I would download a demo of the program (unless you that good, and don't need it)...
I have a demo of Photo-Graffix 3.3
http://www.photo-graffix.com/trial.php
'
Ok, to begin...
To get a variable to be echoed out to the 'checkout.php' page using photo-graffix is like such:
Where ever you put this code in the checkout.php page:
<?php $name = $_GET['photoname']; echo $name ?>
'
It will display the name of the image name that you specify on the url string such as 'YourPic' (without the quotes) as specified in the url below.
http://www.yourdomain.com/graffix/checkout.php?photoname=YourPic
'
Note: YourPic (as specified in the above url) can be anything, I will use it for the item number for each image in the gallery. Also, if anyone has another suggestion for the url above that will substitute 'YourPic' for a variable based on the image clicked on in the gallery (not sure if photo-graffix works like that), but that would be awesome if you found out, so I don't have to type in each item number for each url. But if need be, I will do it.
Now I also would need the description to be echoed out onto the checkout page as well, keep in mind this is only a basic checkout page, so not to be technical. Now I haven't tested the code below so I don't know if it works, but I will need the description as well to be echoed to the checkout page. This code was emailed to me from photo-graffix, they said it works. I haven't tested it yet though.
http://www.yourdomain.com/gallery/checkout.php?item=photoname&descriptio...
'
Now that you know that, a basic checkout page may look like this:
<!-- CONTENT STARTS -->
<p align="center"><font face="Verdana">Checkout Page</font></p>
<table border="0">
<tr>
<td><font face="Verdana" size="2"> Item Name: <?php $name = $_GET['photoname']; echo $name ?> </font></td>
</tr>
</table>
<table border="0">
<tr>
<td><font face="Verdana" size="2">Quantity: </font>
<input type="text" name="T1" size="2"> </td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" height="240" width="596">
<tr>
<td height="20"><font face="Verdana" size="2"> First Name: </font>
<font face="Verdana"><font size="1"><input type="text" name="fname" size="17">
</font>
<font color="#FF0000" size="1">*</font></font></td>
</tr>
<tr>
<td height="20"><font face="Verdana" size="2"> Last Name: </font>
<font face="Verdana"><font size="1"><input type="text" name="lname" size="29">
</font>
<font color="#FF0000" size="1">*</font></font></td>
</tr>
<tr>
<td height="20"><font face="Verdana"><font size="2"> Street Address:
</font><font size="1"><input type="text" name="address" size="31"> </font>
<font size="1" color="#FF0000">*</font><font size="1"> (Please Include Apt #,
Suite #, Floor Etc.)</font></font></td>
</tr>
<tr>
<td height="20"><font face="Verdana"><font size="2"> City: </font>
<font size="1">
<input type="text" name="city" size="24">
<font color="#FF0000">*</font></font></font></td>
</tr>
<tr>
<td height="20"><font face="Verdana"><font size="2"> State: </font>
<font size="1">
<input type="text" name="State" size="2" value="NJ">
<font color="#FF0000">*</font></font></font></td>
</tr>
<tr>
<td height="20"><font face="Verdana"><font size="2"> Zip Code:
</font><font size="1"><input type="text" name="address5" size="9">
<font color="#FF0000">* </font>(Zip+4 Ok)</font></font></td>
</tr>
</table>
<!-- CONTENT ENDS -->
<p align="left"><font color="#FF0000" size="1" face="Verdana">*</font><font face="Verdana" size="2">
</font><font size="1" face="Verdana">Denotes Required Field</font></p>
<a href="print.php">Print Order</a>
Ok..Now for the 'tough' part it's making me Been try so hard to get this, need help bad here.
I want to add a simple shopping cart 'feature' to the checkout.php page that can do the following:
1. Save sessions (very simple shopping cart) so more than one item can be added to the checkout.php page
2. Make Printer Friendly (so the page can be printed on paper without displaying any of the form boxes...Just have it print the text that the person puts into them.)
I have access to a MySQL db if needed.
Here's a page where you can find help with a simple shopping cart, that's exactly what I need, and maybe it will help refresh your memory if need be.
http://www.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart
'
I Thank all who help with this project!
benf posted this at 00:42 — 24th June 2007.
They have: 426 posts
Joined: Feb 2005
to make the page printerable you need to create a media="print" css file!!!
As for sessions, you obviously know about them so what are you struggling with.
Lets see what you have done in PHP so we can see where the problem is?
Good Value Professional VPS Hosting
Brian07002 posted this at 02:34 — 24th June 2007.
They have: 16 posts
Joined: Aug 2004
I can't seem to get a strong hold on the project, other than finding the info. It's like if I put half of it together, I'd be lucky...It's just alot of testing, and re-testing, and I *really* can't keep testing due to the fact that I have a tight time schedule, specifically testing the code for the sessions part...Give me some credit, I attempted it. I guess it wasn't so easy to do after all. If you know php, and sessions, I would have to say that doing a simple checkout page like what I am after should really be a piece of cake given the amount of information on that page I specified in my original post.
I appreciate your feed-back however.
Thanks!
-Brian
kb posted this at 09:00 — 24th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Here's what I did a few months ago when I needed a 'checkout' system:
-Created a Google Checkout account
-Wrote a PHP/JS system that stores all of the user's choices in a cookie [JS], and pulls all of the store info from databases (using specified product codes, etc.) [PHP]
-When they decide to check out, they click a button, which runs a JS file that translates the cookie (that has all of their choices) into the appropriate Google Checkout code, all while displaying contents
-When they click "next" it actually takes them to the Google Checkout page
....DONE!
It was actually pretty easy, easier than I just made it sound. If you follow the Google Checkout API/Docs it'll make sense, pretty quickly.
So, that would be my suggestion. Ditch whatever you're trying to do now, and use the Google system. It's quick and easy, and the processing is alot cheaper than other places like PayPal or CCBill.
Brian07002 posted this at 12:26 — 24th June 2007.
They have: 16 posts
Joined: Aug 2004
Let me make something *clear* this is a mail-order form, where the customer is going to be able to print out on paper and mail it or fax it to me, NOT a page that's going to link to google to checkout or whatever.
Sorry if you meant something different but it sounded like that is what you mean. This is like a checkout page going back to the 'cave man' days of online ordering. That's what I am looking for.
kb posted this at 03:13 — 25th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Oh. Why would you want to do that? That makes no sense to me.
Brian07002 posted this at 14:11 — 25th June 2007.
They have: 16 posts
Joined: Aug 2004
I want to offer two ways for payments, one way will be online for people who feel secure paying through the website and one will be offline for people who don't feel secure sending their credit card information throught the website...They just send a check or money order payment through fax or postal mail. That's where the checkout.php form comes into play. Hope that clairifies the situation for you.
greg posted this at 15:07 — 4th July 2007.
He has: 1,581 posts
Joined: Nov 2005
You may be aware, but just incase you are not..
Paypal's checkout system offers many ways of payments
The virtual terminal comes included with the 'pro' paypal checkout package, and you apply for one with the standard package
the pro is £20 per month, the standard is free to use, but as with all their packages, there is a percentage charge per transaction
the highest being 3.4% (some 1.4%)
The pro package also lets your customer checkout back at a specified url at your website
the others checkout at paypal website
Personally, all my dealings with paypal have been 100%. Telephone assistance very helpful, and they assist you with putting the required code on your website
The other good thing of using paypal, is many people know of it and know it's trusted. So when they see your "CHECKOUT" button or link and see the paypal logo they should feel secure in processing their order.
Good luck
Brian07002 posted this at 19:18 — 4th July 2007.
They have: 16 posts
Joined: Aug 2004
My point here is to have an OFFLINE PAYMENT method. Paypal is an online payment method, NO MATTER WHICH WAY YOU LOOK AT IT.
I was NOT Screaming at you, I was just making a point, note there's no exclamation point at the end of the CAPS Statement.
Also, I am using paypal already as an online payment method. This is particually for an offline payment method.
greg posted this at 22:06 — 4th July 2007.
He has: 1,581 posts
Joined: Nov 2005
urm.....urm.....??!?
did you read my post?
If they are "online" to view your website, to see your products...they are, er, well, online?! they have to download your php form that has all the details to order offline.
I am sure you have very good reason for requiring to provide an offline payment method, although there are very few instances when an "online" website will provide an "offline" payment method, otherwise you might as well open a physical shop
btw, when you use uppercase, it is as though you are shouting...HOWEVER YOU LOOK AT IT!
GOOD LUCK!
Brian07002 posted this at 00:23 — 5th July 2007.
They have: 16 posts
Joined: Aug 2004
This is all I need done:
A simple checkout php page, one in which connects to the photo-graffix gallery script:
http://www.photo-graffix.com
'Here's a break down of functionality:
1. Load Gallery
2. In the Description area of any given image is a descript. and a buy link.
3. Click the buy link which opens the checkout.php
4. Checkout.php page contains:
* Form where they fill in shipping info. Name, Address, City, State etc..
* Name of the item they clicked on
* Description of the item they clicked on
Also, a way to save what they added to the checkout page so they could go back to the gallery to order more if they wanted and keep the other items previously added to their 'cart' or session.
The checkout php needs to be printed and faxed back to me for processing.
Hope that helps.
kb posted this at 01:14 — 26th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Ok, but still...
What I said can still be applied to you. Just give the option to print, as well as continue with the checkout. The process is the same, with a slightly different end result.
Brian07002 posted this at 11:53 — 26th June 2007.
They have: 16 posts
Joined: Aug 2004
The end result that I am trying to achieve is this:
http://www.stocksignalpro.com/SSP279order_mail.htm
'I've been working at it (the checkout.php page), and this is what I got so far: And oh,
like I say, this will be 'connected' with photo-graffix flash gallery. My problem is at this point is that I need to put whatever was clicked on
from the gallery, which is:
$name = $_GET['photoname'];
' into a table, similar to how a shopping cart works, where as the items are displayed in an table inan itemized form such as:
The output should be something like this, but each line should be
different (photoname is the actual name of the product) and it
shouldn't display the same item name. Another words, the code is
using sessions, so Item 1 should be the first item put in, the second
item would be the second item that was clicked on etc..etc..
<table border="0">
<tr>
<td> Item 1: </td>
<td> echo $name = $_GET['photoname'];</td>
</tr>
<tr>
<td> Item 2: </td>
<td> echo $name = $_GET['photoname'];</td>
</tr>
<tr>
<td> Item 3:</td>
<td> echo $name = $_GET['photoname'];</td>
</tr>
</table>
<?php
Php
// Start a session.
session_start();
// Grab information from URL.
$name = $_GET['photoname'];
$desc = $_GET['description'];
// If this is the first time viewing page make the cart session var an array.
if (!$_SESSION['cart'])
{
$_SESSION['cart'] = array();
}
// Transfer array.
$arrayCART = $_SESSION['cart'];
// Add tiems to the item array.
$arrayITEM['NAME'] = $name;
$arrayITEM['DESC'] = $desc;
// If they have submited a form they arnt going to need to add another item so we wont.
if (!$_POST['submit'])
{
// Put informtion into the cart.
array_push($arrayCART, $arrayITEM);
// Store the cart back in the session.
$_SESSION['cart'] = $arrayCART;
}
// DISPLAYS BEFORE ORDER INFORMATION //
echo '<table border=\'0\'>' . \"\n\";
// // // // // // // // // // // // //
foreach ($arrayCART as $id => $name)
{
// DISPLAYS INBETWEEN ITEMS BEFORE //
// // // // // // // // // // // // //
foreach ($arrayCART[$id] as $key => $info)
{
// DISPLAYS PER EACH ITEM FIELD //
echo \"\t\" . '<tr>' . \"\n\";
echo \"\t\t\" . '<td>' . $key . ':' . $info . '</td>' . \"\n\";
echo \"\t\" . '</tr>' . \"\n\";
// // // // // // // // // // // // //
}
// DISPLAYS INBETWEEN ITEMS AFTER //
echo \"\t\" . '<tr>' . \"\n\";
echo \"\t\t\" . '<td> </td>' . \"\n\";
echo \"\t\" . '</tr>' . \"\n\";
// // // // // // // // // // // // //
}
// DISPLAYS AFTER ORDER INFORMATION //
echo '</table>' . \"\n\";
// // // // // // // // // // // // //
echo '<br>' . \"\n\";
echo '<br>' . \"\n\";
echo '<br>' . \"\n\";
// If the form is submited we want to display the information they entered.
if ($_POST['submit'])
{
// Process submition.
$f_name = $_POST['f_name'];
$f_addr = $_POST['f_addr'];
$f_city = $_POST['f_city'];
$f_state = $_POST['f_state'];
$f_zipcode = $_POST['f_zipcode'];
$f_phone = $_POST['f_phone'];
$f_email = $_POST['f_email'];
// Put submited information into a varible to display (You dont really need to store if but its standard for me).
$message .= 'Name:' . $f_name . \"<br>\n\";
$message .= 'Address:' . $f_addr . \"<br>\n\";
$message .= 'City:' . $f_city . \"<br>\n\";
$message .= 'State:' . $f_state . \"<br>\n\";
$message .= 'Zip:' . $f_zipcode . \"<br>\n\";
$message .= 'Phone:' . $f_phone . \"<br>\n\";
$message .= 'Email:' . $f_email . \"<br>\n\";
// Display the message.
echo $message;
}
else
{
// If they have not submited there order then we want to give them the option too.
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// There is nothing really crazy about this code below, just standard html.
echo ' <h2>Continie Checkout</h2>' . \"\n\";
echo ' <table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"500\" bgcolor=\"#EEEFEE\" style=\"border: D6DFE8 solid 1px\">' . \"\n\";
echo ' <tr valign=\"top\">' . \"\n\";
echo ' <td></td><td><div class=\"noprint\"><p align=\"left\"><font face=\"Verdana\" size=\"2\" color=\"FF0000\"><b>Info Text</b></font></div></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <form method=\"post\" name=\"myform\">' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> Name:</font></td>' . \"\n\";
echo ' <td width=\"251\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=40 size=40 name=\"f_name\" tabindex=\"1\" value=\"\">' . \"\n\";
echo ' </font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> Address:</font></td>' . \"\n\";
echo ' <td width=\"251\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=40 size=40 name=\"f_addr\" tabindex=\"2\"> ' . \"\n\";
echo ' </font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> City:</font></td>' . \"\n\";
echo ' <td width=\"251\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=20 size=20 name=\"f_city\" tabindex=\"3\"></font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> State:</font></td>' . \"\n\";
echo ' <td width=\"251\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <select name=\"f_state\" tabindex=\"4\">' . \"\n\";
echo ' <option value=\"0\">State...</option>' . \"\n\";
echo ' <option value=\"Na\">Other / Not USA</option>' . \"\n\";
echo ' <option value=\"AL\" >Alabama</option>' . \"\n\";
echo ' <option value=\"AK\" >Alaska</option>' . \"\n\";
echo ' <option value=\"AZ\" >Arizona</option>' . \"\n\";
echo ' <option value=\"AR\" >Arkansas</option>' . \"\n\";
echo ' <option value=\"CA\" >California</option>' . \"\n\";
echo ' <option value=\"CO\" >Colorado</option>' . \"\n\";
echo ' <option value=\"CT\" >Connecticut</option>' . \"\n\";
echo ' <option value=\"DE\" >Delaware</option>' . \"\n\";
echo ' <option value=\"DC\" >District of Columbia</option>' . \"\n\";
echo ' <option value=\"FL\" >Florida</option>' . \"\n\";
echo ' <option value=\"GA\" >Georgia</option>' . \"\n\";
echo ' <option value=\"HI\" >Hawaii</option>' . \"\n\";
echo ' <option value=\"ID\" >Idaho</option>' . \"\n\";
echo ' <option value=\"IL\" >Illinois</option>' . \"\n\";
echo ' <option value=\"IN\" >Indiana</option>' . \"\n\";
echo ' <option value=\"IO\" >Iowa</option>' . \"\n\";
echo ' <option value=\"KS\" >Kansas</option>' . \"\n\";
echo ' <option value=\"KY\" >Kentucky</option>' . \"\n\";
echo ' <option value=\"LA\" >Louisiana</option>' . \"\n\";
echo ' <option value=\"ME\" >Maine</option>' . \"\n\";
echo ' <option value=\"MD\" >Maryland</option>' . \"\n\";
echo ' <option value=\"MA\" >Massachusetts</option>' . \"\n\";
echo ' <option value=\"MI\" >Michigan</option>' . \"\n\";
echo ' <option value=\"MN\" >Minnesota</option>' . \"\n\";
echo ' <option value=\"MS\" >Mississippi</option>' . \"\n\";
echo ' <option value=\"MO\" >Missouri</option>' . \"\n\";
echo ' <option value=\"MT\" >Montana</option>' . \"\n\";
echo ' <option value=\"NE\" >Nebraska</option>' . \"\n\";
echo ' <option value=\"NV\" >Nevada</option>' . \"\n\";
echo ' <option value=\"NH\" >New Hampshire</option>' . \"\n\";
echo ' <option value=\"NJ\" >New Jersey</option>' . \"\n\";
echo ' <option value=\"NM\" >New Mexico</option>' . \"\n\";
echo ' <option value=\"NY\" >New York</option>' . \"\n\";
echo ' <option value=\"NC\" >North Carolina</option>' . \"\n\";
echo ' <option value=\"ND\" >North Dakota</option>' . \"\n\";
echo ' <option value=\"OH\" >Ohio</option>' . \"\n\";
echo ' <option value=\"OK\" >Oklahoma</option>' . \"\n\";
echo ' <option value=\"OR\" >Oregon</option>' . \"\n\";
echo ' <option value=\"PA\" >Pennsylvania</option>' . \"\n\";
echo ' <option value=\"RI\" >Rhode Island</option>' . \"\n\";
echo ' <option value=\"SC\" >South Carolina</option>' . \"\n\";
echo ' <option value=\"SD\" >South Dakota</option>' . \"\n\";
echo ' <option value=\"TN\" >Tennessee</option>' . \"\n\";
echo ' <option value=\"TX\" >Texas</option>' . \"\n\";
echo ' <option value=\"UT\" >Utah</option>' . \"\n\";
echo ' <option value=\"VT\" >Vermont</option>' . \"\n\";
echo ' <option value=\"VA\" >Virginia</option>' . \"\n\";
echo ' <option value=\"WA\" >Washington</option>' . \"\n\";
echo ' <option value=\"WV\" >West Virginia</option>' . \"\n\";
echo ' <option value=\"WI\" >Wisconsin</option>' . \"\n\";
echo ' <option value=\"WY\" >Wyoming</option>' . \"\n\";
echo ' </select></font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> Zip:</font></td>' . \"\n\";
echo ' <td width=\"251\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=10 size=10 name=\"f_zipcode\" tabindex=\"5\">' . \"\n\";
echo ' </font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> Phone#:</font></td>' . \"\n\";
echo ' <td width=\"243\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=16 size=16 name=\"f_phone\" tabindex=\"7\">' . \"\n\";
echo ' </font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td width=\"100\" height=\"31\"><font face=\"Verdana\" size=\"2\"> E-mail:</font></td>' . \"\n\";
echo ' <td width=\"253\" height=\"31\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input maxlength=40 size=40 name=\"f_email\" tabindex=\"8\" value=\"\">' . \"\n\";
echo ' </font></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' <tr>' . \"\n\";
echo ' <td colspan=\"2\" width=\"520\"><div class=\"noprint\"><p align=\"center\"><font face=\"Verdana\" size=\"2\">' . \"\n\";
echo ' <input type=submit value=\"Click Here to Submit\" name=submit tabindex=\"9\">' . \"\n\";
echo ' </font></p></div></td>' . \"\n\";
echo ' </tr>' . \"\n\";
echo ' </form>' . \"\n\";
echo ' </table>' . \"\n\";
}
BACK</a></div>
?>
kb posted this at 20:01 — 26th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Ok, you realize that an html page can't accept your PHP code.... right? You also realize that you can't just stick $_GET statements randomly in your page? They either have to be inside a php block, or declared using short tags like <?=$_GET..?>. Also, you can't just echo a $_GET value, you have to use strip_tags() to make sure that all you get is that value.
I'll comb through your actual code later tonight, but I think you might have alot more problems than you realize.
Brian07002 posted this at 21:11 — 26th June 2007.
They have: 16 posts
Joined: Aug 2004
Hey I really appreciate your help/effort in this, all I am
trying to accomplish is a simple checkout page that is
simple like:
http://www.stocksignalpro.com/SSP279order_
mail.htm
But I need to 'interface' with the Photo-Graffix so that
when the person decides, hey I want to purchase
that item, the photoname & description variables that
are part of photo-graffix gallery will be displayed in
their true form as the actual name and actual
description on the checkout page. Of course I am going
to need the checkout page to have a button to print it
because it will not be to submit by email, it will be for
fax, and / or postal mail orders only. I know somone
could do this, please help.
Thanks again for your time and effort.
Brian07002 posted this at 17:39 — 27th June 2007.
They have: 16 posts
Joined: Aug 2004
Are you still looking through that code?
kb posted this at 23:13 — 27th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Jesus. Put that fire in your pants out.
I had a very rough day yesterday, so I didn't look. I have a few things to do, and I will for sure look at it later.
Remember that I do this as a favor, and not as a contract. Meaning that you don't always have a quick turnaround time.
Brian07002 posted this at 23:27 — 27th June 2007.
They have: 16 posts
Joined: Aug 2004
You didn't have to take it the wrong way, I just wanted to know if you had a look at the code, assuming it's as bad as you say it is...As far as you having a bad day, you should keep that personal and not share it with the rest of the community, that only makes you look bad. I only wanted to know if you looked at the code. sheesh! I have bad days too, but you don't see me posting comments like that.
kb posted this at 02:25 — 28th June 2007.
He has: 1,380 posts
Joined: Feb 2002
Brian,
You have 10 posts. You will find that, after you've been here long enough (despite having been a member since 2004... how does that work out?), that people share information here. I wasn't telling you to be personal, I was explaining why I didn't follow through on what I said I would. I thought that you, like most of the members here, would appreciate being treated as a human being, and not just randomly ignored without explanation.
Now, for your code....
Like I said before, things within HTML need to be like:
<?php echo $name = $_GET['photoname']; ?>
instead of
echo $name = $_GET['photoname'];
Within your PHP code...
<?php
$name = $_GET['photoname'];
?>
should be
<?php
$name = strip_tags($_GET['photoname']);
?>
...actually before I go any further, let's do this:
-make the changes I've referenced
-go through ALL of your code and make sure you're doing things properly. strip_tags() is your friend for $_POST and $_GET items. Arrays should be declared. You should check your sessions with a ...little... more security.
You are doing very basic things either wrong, or in a method that is not suggested. More times than not, if you clean up your code and follow the requirements... you may find the problem you're looking for.
Comb through your code, and repost it. After that, it should be relatively simple to find the one mistake that matters, and not all the other little ones that are distracting.
Brian07002 posted this at 04:08 — 28th June 2007.
They have: 16 posts
Joined: Aug 2004
Don't take this the wrong way, but I understand what you mean with the
<?php
and
?>
My knowledge in this area is only capable of knowing that if I were to add this into a table below the checkout form:
<?php echo $name = $_GET['photoname']; ?>
'It would produce the name of the image clicked on from the gallery, but how would the code need to be if a different image from the gallery were to be clicked on and I wanted it to appear right under the first if each image can't have it's own variable like photoname2, photoname3 etc..?
Here's the code that I have working up to what I stated above:
<?php
// Start a session.
session_start();
// Grab information from URL.
$name = $_GET['photoname'];
$desc = $_GET['description'];
// If this is the first time viewing page make the cart session var an array.
if (!$_SESSION['cart'])
{
$_SESSION['cart'] = array();
}
// Transfer array.
$arrayCART = $_SESSION['cart'];
// Add tiems to the item array.
$arrayITEM['NAME'] = $name;
$arrayITEM['DESC'] = $desc;
// If they have submited a form they arnt going to need to add another item so we wont.
if (!$_POST['submit'])
{
// Put informtion into the cart.
array_push($arrayCART, $arrayITEM);
// Store the cart back in the session.
$_SESSION['cart'] = $arrayCART;
}
// DISPLAYS BEFORE ORDER INFORMATION //
echo '<table border=\'0\'>' . "\n";
// // // // // // // // // // // // //
foreach ($arrayCART as $id => $name)
{
// DISPLAYS INBETWEEN ITEMS BEFORE //
// // // // // // // // // // // // //
foreach ($arrayCART[$id] as $key => $info)
{
// DISPLAYS PER EACH ITEM FIELD //
echo "\t" . '<tr>' . "\n";
echo "\t\t" . '<td>' . $key . ':' . $info . '</td>' . "\n";
echo "\t" . '</tr>' . "\n";
// // // // // // // // // // // // //
}
// DISPLAYS INBETWEEN ITEMS AFTER //
echo "\t" . '<tr>' . "\n";
echo "\t\t" . '<td> </td>' . "\n";
echo "\t" . '</tr>' . "\n";
// // // // // // // // // // // // //
}
// DISPLAYS AFTER ORDER INFORMATION //
echo '</table>' . "\n";
// // // // // // // // // // // // //
echo '<br>' . "\n";
echo '<br>' . "\n";
echo '<br>' . "\n";
// If the form is submited we want to display the information they entered.
if ($_POST['submit'])
{
// Process submition.
$f_name = $_POST['f_name'];
$f_addr = $_POST['f_addr'];
$f_city = $_POST['f_city'];
$f_state = $_POST['f_state'];
$f_zipcode = $_POST['f_zipcode'];
$f_phone = $_POST['f_phone'];
$f_email = $_POST['f_email'];
// Put submited information into a varible to display (You dont really need to store if but its standard for me).
$message .= 'Name:' . $f_name . "<br>\n";
$message .= 'Address:' . $f_addr . "<br>\n";
$message .= 'City:' . $f_city . "<br>\n";
$message .= 'State:' . $f_state . "<br>\n";
$message .= 'Zip:' . $f_zipcode . "<br>\n";
$message .= 'Phone:' . $f_phone . "<br>\n";
$message .= 'Email:' . $f_email . "<br>\n";
// Display the message.
echo $message;
}
else
{
// If they have not submited there order then we want to give them the option too.
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE //
// There is nothing really crazy about this code below, just standard html.
echo ' <h2>Continue Checkout</h2>' . "\n";
echo ' <table border="0" cellpadding="3" cellspacing="0" width="500" bgcolor="#EEEFEE" style="border: D6DFE8 solid 1px">' . "\n";
echo ' <tr valign="top">' . "\n";
echo ' <td></td><td><div class="noprint"><p align="left"><font face="Verdana" size="2" color="FF0000"><b>Info Text</b></font></div></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <form method="post" name="myform">' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> Name:</font></td>' . "\n";
echo ' <td width="251" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40 name="f_name" tabindex="1" value="">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> Address:</font></td>' . "\n";
echo ' <td width="251" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40 name="f_addr" tabindex="2"> ' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> City:</font></td>' . "\n";
echo ' <td width="251" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=20 size=20 name="f_city" tabindex="3"></font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> State:</font></td>' . "\n";
echo ' <td width="251" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <select name="f_state" tabindex="4">' . "\n";
echo ' <option value="0">State...</option>' . "\n";
echo ' <option value="Na">Other / Not USA</option>' . "\n";
echo ' <option value="AL" >Alabama</option>' . "\n";
echo ' <option value="AK" >Alaska</option>' . "\n";
echo ' <option value="AZ" >Arizona</option>' . "\n";
echo ' <option value="AR" >Arkansas</option>' . "\n";
echo ' <option value="CA" >California</option>' . "\n";
echo ' <option value="CO" >Colorado</option>' . "\n";
echo ' <option value="CT" >Connecticut</option>' . "\n";
echo ' <option value="DE" >Delaware</option>' . "\n";
echo ' <option value="DC" >District of Columbia</option>' . "\n";
echo ' <option value="FL" >Florida</option>' . "\n";
echo ' <option value="GA" >Georgia</option>' . "\n";
echo ' <option value="HI" >Hawaii</option>' . "\n";
echo ' <option value="ID" >Idaho</option>' . "\n";
echo ' <option value="IL" >Illinois</option>' . "\n";
echo ' <option value="IN" >Indiana</option>' . "\n";
echo ' <option value="IO" >Iowa</option>' . "\n";
echo ' <option value="KS" >Kansas</option>' . "\n";
echo ' <option value="KY" >Kentucky</option>' . "\n";
echo ' <option value="LA" >Louisiana</option>' . "\n";
echo ' <option value="ME" >Maine</option>' . "\n";
echo ' <option value="MD" >Maryland</option>' . "\n";
echo ' <option value="MA" >Massachusetts</option>' . "\n";
echo ' <option value="MI" >Michigan</option>' . "\n";
echo ' <option value="MN" >Minnesota</option>' . "\n";
echo ' <option value="MS" >Mississippi</option>' . "\n";
echo ' <option value="MO" >Missouri</option>' . "\n";
echo ' <option value="MT" >Montana</option>' . "\n";
echo ' <option value="NE" >Nebraska</option>' . "\n";
echo ' <option value="NV" >Nevada</option>' . "\n";
echo ' <option value="NH" >New Hampshire</option>' . "\n";
echo ' <option value="NJ" >New Jersey</option>' . "\n";
echo ' <option value="NM" >New Mexico</option>' . "\n";
echo ' <option value="NY" >New York</option>' . "\n";
echo ' <option value="NC" >North Carolina</option>' . "\n";
echo ' <option value="ND" >North Dakota</option>' . "\n";
echo ' <option value="OH" >Ohio</option>' . "\n";
echo ' <option value="OK" >Oklahoma</option>' . "\n";
echo ' <option value="OR" >Oregon</option>' . "\n";
echo ' <option value="PA" >Pennsylvania</option>' . "\n";
echo ' <option value="RI" >Rhode Island</option>' . "\n";
echo ' <option value="SC" >South Carolina</option>' . "\n";
echo ' <option value="SD" >South Dakota</option>' . "\n";
echo ' <option value="TN" >Tennessee</option>' . "\n";
echo ' <option value="TX" >Texas</option>' . "\n";
echo ' <option value="UT" >Utah</option>' . "\n";
echo ' <option value="VT" >Vermont</option>' . "\n";
echo ' <option value="VA" >Virginia</option>' . "\n";
echo ' <option value="WA" >Washington</option>' . "\n";
echo ' <option value="WV" >West Virginia</option>' . "\n";
echo ' <option value="WI" >Wisconsin</option>' . "\n";
echo ' <option value="WY" >Wyoming</option>' . "\n";
echo ' </select></font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> Zip:</font></td>' . "\n";
echo ' <td width="251" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=10 size=10 name="f_zipcode" tabindex="5">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> Phone#:</font></td>' . "\n";
echo ' <td width="243" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=16 size=16 name="f_phone" tabindex="7">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font face="Verdana" size="2"> E-mail:</font></td>' . "\n";
echo ' <td width="253" height="31"><font face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40 name="f_email" tabindex="8" value="">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td colspan="2" width="520"><div class="noprint"><p align="center"><font face="Verdana" size="2">' . "\n";
echo ' <input type=submit value="Click Here to Submit" name=submit tabindex="9">' . "\n";
echo ' </font></p></div></td>' . "\n";
echo ' </tr>' . "\n";
echo ' </form>' . "\n";
echo ' </table>' . "\n";
}
?>
Brian07002 posted this at 16:15 — 29th June 2007.
They have: 16 posts
Joined: Aug 2004
Ok,
I've done that...
Here's the new code: Note I only
<?php
/**
* @author Travis Person
* @copyright 2007
*
* Developed with PHP Designer 2007
* <a href="http://mpsoftware.de" title="http://mpsoftware.de">http://mpsoftware.de</a>
*
*/
// Start a session.
session_start();
// Grab information from URL.
$name = strip_tags($_GET['photoname']);
$desc = strip_tags($_GET['description']);
// If this is the first time viewing page make the
cart session var an array.
if (!$_SESSION['cart'])
{
$_SESSION['cart'] = array();
}
// Transfer array.
$arrayCART = $_SESSION['cart'];
// Add items to the item array.
$arrayITEM['NAME'] = $name;
$arrayITEM['DESC'] = $desc;
// If they have submited a form they arnt going to need to add
another item so we wont.
if (!$_POST['submit'])
{
// Put informtion into the cart.
array_push($arrayCART, $arrayITEM);
// Store the cart back in the session.
$_SESSION['cart'] = $arrayCART;
}
// DISPLAYS BEFORE ORDER INFORMATION //
echo '<table border=\'0\'>' . "\n";
// // // // // // // // // // // // //
foreach ($arrayCART as $id => $name)
{
// DISPLAYS INBETWEEN ITEMS BEFORE //
// // // // // // // // // // // // //
foreach ($arrayCART[$id] as $key => $info)
{
// DISPLAYS PER EACH ITEM FIELD //
echo "\t" . '<tr>' . "\n";
echo "\t\t" . '<td>' . $key . ':' . $info . '</td>' . "\n";
echo "\t" . '</tr>' . "\n";
// // // // // // // // // // // // //
}
// DISPLAYS INBETWEEN ITEMS AFTER //
echo "\t" . '<tr>' . "\n";
echo "\t\t" . '<td> </td>' . "\n";
echo "\t" . '</tr>' . "\n";
// // // // // // // // // // // // //
}
// DISPLAYS AFTER ORDER INFORMATION //
echo '</table>' . "\n";
// // // // // // // // // // // // //
echo '<br>' . "\n";
echo '<br>' . "\n";
echo '<br>' . "\n";
// If the form is submited we want to display the information
they entered.
if ($_POST['submit'])
{
// Process submition.
$f_name = $_POST['f_name'];
$f_addr = $_POST['f_addr'];
$f_city = $_POST['f_city'];
$f_state = $_POST['f_state'];
$f_zipcode = $_POST['f_zipcode'];
$f_phone = $_POST['f_phone'];
$f_email = $_POST['f_email'];
// Put submited information into a varible to display (You
dont really need to store if but its standard for me).
$message .= 'Name:' . $f_name . "<br>\n";
$message .= 'Address:' . $f_addr . "<br>\n";
$message .= 'City:' . $f_city . "<br>\n";
$message .= 'State:' . $f_state . "<br>\n";
$message .= 'Zip:' . $f_zipcode . "<br>\n";
$message .= 'Phone:' . $f_phone . "<br>\n";
$message .= 'Email:' . $f_email . "<br>\n";
// Display the message.
echo $message;
}
else
{
// If they have not submited there order then we want to give
them the option too.
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE
//
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE
//
// THIS IS JUST A BUNCH OF HTML CODE DISPLAYED LINE BY LINE
//
// There is nothing really crazy about this code below, just
standard html.
echo ' <h2>Continue Checkout</h2>' . "\n";
echo ' <table border="0" cellpadding="3"
cellspacing="0" width="500" bgcolor="#EEEFEE" style="border: D6DFE8
solid 1px">' . "\n";
echo ' <tr valign="top">' . "\n";
echo ' <td></td><td><div class="noprint"><p
align="left"><font face="Verdana" size="2" color="FF0000"><b>Info
Text</b></font></div></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <form method="post"
name="myform">' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> Name:</font></td>' . "\n";
echo ' <td width="251" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40
name="f_name" tabindex="1" value="">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> Address:</font></td>' . "\n";
echo ' <td width="251" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40
name="f_addr" tabindex="2"> ' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> City:</font></td>' . "\n";
echo ' <td width="251" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=20 size=20
name="f_city" tabindex="3"></font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> State:</font></td>' . "\n";
echo ' <td width="251" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <select name="f_state"
tabindex="4">' . "\n";
echo ' <option
value="0">State...</option>' . "\n";
echo ' <option
value="Na">Other / Not USA</option>' . "\n";
echo ' <option value="AL"
>Alabama</option>' . "\n";
echo ' <option value="AK"
>Alaska</option>' . "\n";
echo ' <option value="AZ"
>Arizona</option>' . "\n";
echo ' <option value="AR"
>Arkansas</option>' . "\n";
echo ' <option value="CA"
>California</option>' . "\n";
echo ' <option value="CO"
>Colorado</option>' . "\n";
echo ' <option value="CT"
>Connecticut</option>' . "\n";
echo ' <option value="DE"
>Delaware</option>' . "\n";
echo ' <option value="DC"
>District of Columbia</option>' . "\n";
echo ' <option value="FL"
>Florida</option>' . "\n";
echo ' <option value="GA"
>Georgia</option>' . "\n";
echo ' <option value="HI"
>Hawaii</option>' . "\n";
echo ' <option value="ID"
>Idaho</option>' . "\n";
echo ' <option value="IL"
>Illinois</option>' . "\n";
echo ' <option value="IN"
>Indiana</option>' . "\n";
echo ' <option value="IO"
>Iowa</option>' . "\n";
echo ' <option value="KS"
>Kansas</option>' . "\n";
echo ' <option value="KY"
>Kentucky</option>' . "\n";
echo ' <option value="LA"
>Louisiana</option>' . "\n";
echo ' <option value="ME"
>Maine</option>' . "\n";
echo ' <option value="MD"
>Maryland</option>' . "\n";
echo ' <option value="MA"
>Massachusetts</option>' . "\n";
echo ' <option value="MI"
>Michigan</option>' . "\n";
echo ' <option value="MN"
>Minnesota</option>' . "\n";
echo ' <option value="MS"
>Mississippi</option>' . "\n";
echo ' <option value="MO"
>Missouri</option>' . "\n";
echo ' <option value="MT"
>Montana</option>' . "\n";
echo ' <option value="NE"
>Nebraska</option>' . "\n";
echo ' <option value="NV"
>Nevada</option>' . "\n";
echo ' <option value="NH"
>New Hampshire</option>' . "\n";
echo ' <option value="NJ"
>New Jersey</option>' . "\n";
echo ' <option value="NM"
>New Mexico</option>' . "\n";
echo ' <option value="NY"
>New York</option>' . "\n";
echo ' <option value="NC"
>North Carolina</option>' . "\n";
echo ' <option value="ND"
>North Dakota</option>' . "\n";
echo ' <option value="OH"
>Ohio</option>' . "\n";
echo ' <option value="OK"
>Oklahoma</option>' . "\n";
echo ' <option value="OR"
>Oregon</option>' . "\n";
echo ' <option value="PA"
>Pennsylvania</option>' . "\n";
echo ' <option value="RI"
>Rhode Island</option>' . "\n";
echo ' <option value="SC"
>South Carolina</option>' . "\n";
echo ' <option value="SD"
>South Dakota</option>' . "\n";
echo ' <option value="TN"
>Tennessee</option>' . "\n";
echo ' <option value="TX"
>Texas</option>' . "\n";
echo ' <option value="UT"
>Utah</option>' . "\n";
echo ' <option value="VT"
>Vermont</option>' . "\n";
echo ' <option value="VA"
>Virginia</option>' . "\n";
echo ' <option value="WA"
>Washington</option>' . "\n";
echo ' <option value="WV"
>West Virginia</option>' . "\n";
echo ' <option value="WI"
>Wisconsin</option>' . "\n";
echo ' <option value="WY"
>Wyoming</option>' . "\n";
echo ' </select></font></td>'
. "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> Zip:</font></td>' . "\n";
echo ' <td width="251" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=10 size=10
name="f_zipcode" tabindex="5">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> Phone#:</font></td>' . "\n";
echo ' <td width="243" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=16 size=16
name="f_phone" tabindex="7">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td width="100" height="31"><font
face="Verdana" size="2"> E-mail:</font></td>' . "\n";
echo ' <td width="253" height="31"><font
face="Verdana" size="2">' . "\n";
echo ' <input maxlength=40 size=40
name="f_email" tabindex="8" value="">' . "\n";
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td colspan="2" width="520"><div
class="noprint"><p align="center"><font face="Verdana" size="2">' .
"\n";
echo ' <input type=submit value="Click Here
to Submit" name=submit tabindex="9">' . "\n";
echo ' </font></p></div></td>' . "\n";
echo ' </tr>' . "\n";
echo ' </form>' . "\n";
echo ' </table>' . "\n";
}
?>
<br>
<div align="left">
<table border="0" width="985">
<tr>
<td width="491"> Item Number: <?php $name =
strip_tags($_GET['photoname']); ?><?php echo $name ?> </td>
<td width="492"> Description: <?php $desc =
strip_tags($_GET['description']); ?><?php echo $desc ?></td>
</tr>
</table>
</div>
kb posted this at 04:17 — 28th June 2007.
He has: 1,380 posts
Joined: Feb 2002
You are entirely proving what I'm telling you... "echo $name = $whatever" is incorrect. $var = $something_else results in $var storing the value of $something_else. echo $var prints the contents of $var... so why are you "echo $var = $something_else"-ing?
The simple way to do what you want is to have the main page be /whatever.php, and then all links go to /whatever.php?some_var=value
So to "figure out what's been clicked", a link could be "
Brian07002 posted this at 15:17 — 3rd July 2007.
They have: 16 posts
Joined: Aug 2004
Anyone?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.