Solved

correct checkout with php

Posted on 2004-10-29
506 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
Question by:Xtry
    9 Comments
     
    LVL 48

    Expert Comment

    by:hernst42
    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
    well it had problems but it was working now is not working
    0
     
    LVL 2

    Assisted Solution

    by:sandoshvr
    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
     
    LVL 48

    Expert Comment

    by:hernst42
    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
     

    Author Comment

    by:Xtry
    0
     
    LVL 48

    Accepted Solution

    by:
    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
    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
    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
    omg =( i must be blind about 30 mins trying to figureout
    well thanks
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now