Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

correct checkout with php

Posted on 2004-10-29
9
Medium Priority
?
521 Views
Last Modified: 2008-02-26
hello there experts,
i wrote this code, if i have any error please correct me. im trying to make a link like this
https://www2.2checkout.com/2co/buyer/purchase?sid=208628&total=350&quantity=1&cart_order_id=test+name

total = price $350
quantity = 1
cart_order_id = his last and first name

---------
<?PHP
// the url were i have to checkout
$twoco_url = "https://www2.2checkout.com/2co/buyer/purchase?sid=208628";

// total price that i have in the bottom
$final_price = "total";

//  quantity almost all are 1 pack of 500
$product_quantity = "quantity";

// in here i need to generate a unique code for my checkouts
$unique_id_product = "Postcard for $last_name $frist_name";
?>
<html>
<head>
<title>Postcard</title>
</head>
<BODY>
<form name="checkout" action="<?PHP echo $twoco_url; $total; $quantity; $cart_order_id; ?>" method="POST">
<input type="hidden" name="cart_order_id" value="<?PHP echo $unique_id_product; ?>">
<input type="text" name="last_name" maxlength="30"><BR>
<select name="quantity" onchange="total.selectedIndex = selectedIndex;">
<option value="1">250 Pack</option>
<option value="1">500 Pack</option>
</select>
<select name="total" onchange="quantity.selectedIndex = selectedIndex;">
<option value="150">$350</option>
<option value="200">$200</option>
</select>
<br>
  <input name="submit" type='submit' value='Buy Now' >
</form>
</p>
</body>
</html>
0
Comment
Question by:Xtry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12446793
here is a problem:

<?PHP echo $twoco_url; $total; $quantity; $cart_order_id; ?>
should be:
<?php echo $twoco_url; ?>

The  $total; $quantity; $cart_order_id; will do nothing.

to get such an uer, change the method from POST to GET, If the user hists submit that url will be send to your webserver.
0
 

Author Comment

by:Xtry
ID: 12446860
well it had problems but it was working now is not working
0
 
LVL 2

Assisted Solution

by:sandoshvr
sandoshvr earned 400 total points
ID: 12446890
Hi,
replace this
action="<?PHP echo $twoco_url; $total; $quantity; $cart_order_id; ?>"

by
action="<?PHP echo $twoco_url."&total=".$total."&quantity=".$quantity."&cart_order_id=".$cart_order_id; ?>"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Expert Comment

by:hernst42
ID: 12446931
what is your problem excatly. Are the parameters send to https://www2.2checkout.com/2co/buyer/purchase not correct or have they wrong values?
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 800 total points
ID: 12447107
It seems that your script relies on register_globals on.
You might try this:

ction="<?PHP echo $twoco_url."&total=".$_REQUEST['total']."&quantity=".$_REQUEST['quantity']."&cart_order_id=".$_REQUEST['cart_order_id']; ?>"
0
 

Author Comment

by:Xtry
ID: 12447527
ok please correct me my "sid" is not working the rest is working perfect =)

<?PHP
// here is the url were i have to checkout
$twoco_url = "https://www2.2checkout.com/2co/buyer/purchase";
// my 2co id
$my_twoco_id = "208628";
// here is the total price that i have in the bottom
$final_price = "total";
// here is have quantity almost all are 1 pack of 500
$product_quantity = "quantity";
// unique
$unique_product_id = "cart_order_id";
?>
<html>
<head>
<title>Postcard</title>
</head>
<BODY>
<form name="checkout" action="<?PHP echo $twoco_url."?sid=".$my_twoco_id."&total=".$_REQUEST['total']."&quantity=".$_REQUEST['quantity']."&cart_order_id=".$_REQUEST['cart_order_id']; ?> method="POST">
first name: <input type="text" name="cart_order_id" maxlength="30"><BR>
<select name="quantity" onchange="total.selectedIndex = selectedIndex;">
<option value="1">250 Pack</option>
<option value="1">500 Pack</option>
</select>
<select name="total" onchange="quantity.selectedIndex = selectedIndex;">
<option value="150">$350</option>
<option value="200">$200</option>
</select>
<br>
  <input name="submit" type='submit' value='Buy Now' >
</form>
</p>
</body>
</html>
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 800 total points
ID: 12448214
There doesnt seem to be a problem with the sid code wise however you had a missing "

here:

<form name="checkout" action="<?PHP echo $twoco_url."?sid=".$my_twoco_id."&total=".$_REQUEST['total']."&quantity=".$_REQUEST['quantity']."&cart_order_id=".$_REQUEST['cart_order_id']; ?>" method="POST">

Just before method.
0
 

Author Comment

by:Xtry
ID: 12448291
omg =( i must be blind about 30 mins trying to figureout
well thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question