SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot mrtdirect's Avatar
    Join Date
    Aug 2002
    Location
    LONDON / UK
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Checkout script

    I am trying to create simple checkout system with PHP by using sessions.
    I thought using sessions to store cart details on variables and after payment passing it to the MySQL database

    checkout.php
    --------------------------------------------
    <?php
    session_start
    ();
    $product_name= "some value";
    $product_price= "some value";
    session_register("product_name"
    );

    session_register("product_price");
    echo('<A href="https://www.nochex.com/nochex.dll/checkout?email=nochex@domain.com&amount='.$productprice.'&returnurl=http://www.domain.com/success.php">Click here to pay with nochex</a>');
    ?>


    success.php
    --------------------------------------
    <?
    $username="username";
    $password="password";
    $database="your_database";

    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database" );

    session_start();
    $query = "INSERT INTO orders VALUES ('',$product_name,$product_price)";

    mysql_query($query);
    echo('Thankyou for choosing our services. Your payment is recieved');

    ?>


    I need to know if i am doing everything correct.
    VENI VIDI VICI

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    fixed some erros and made some minor changes, hope it helps you:
    PHP Code:
    <?
    session_start
    ();
    $product_name"some value";
    $product_price"some value";
    $_SESSION['product_name'] = $product_name;
    $_SESSION['product_price'] = $product_price;
    $email urlencode('nochex@domain.com');
    $url urlencode('http://www.domain.com/success.php');
    echo(
    '<A href="https://www.nochex.com/nochex.dll/checkout?'.$email.'&amount='.$productprice.'&returnurl='.$url.'">Click here to pay with nochex</a>');
    ?>
    PHP Code:
    <?
    $username
    ="username";
    $password="password";
    $database="your_database";
    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database" );
    session_start();
    $query 'INSERT INTO orders VALUES (\'\',\''.$_SESSION['product_name'].'\',\''.$_SESSION['product_price'].'\')';
    mysql_query($query);
    echo(
    'Thank you for choosing our services. Your payment is recieved');
    ?>
    note that you need I think php 4.1+ for this
    - website

  3. #3
    SitePoint Zealot mrtdirect's Avatar
    Join Date
    Aug 2002
    Location
    LONDON / UK
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you mate. This script rocked my world.
    VENI VIDI VICI

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - website


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •