SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 52
  1. #1
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Experts with arrays... help needed pleasy.

    The following is only a snippet of 30 items that I need to have entered into a Mysql database and also sent through email. What is the proper procedure to set this into an array so that I can manipulate these items without having 30 rows of quantity/number/item/price in the database.

    Here is what I have:
    PHP Code:
    $quantity1=$_REQUEST["quantity1"]; 
    $number1=$_REQUEST["number1"]; 
    $item1=$_REQUEST["item1"]; 
    $price1=$_REQUEST["price1"];
    $quantity2=$_REQUEST["quantity2"]; 
    $number2=$_REQUEST["number2"]; 
    $item2=$_REQUEST["item2"];  
    $price2=$_REQUEST["price2"];  //this continues til $blah30 (30 for each)

    // into email
    $quantity1 $number1 $item1 $price1
    $quantity2 $number2 $item2 $price2 
    // also til $blah30 

    How do I do an array so that I can just have a column for quantity, number, item allowing the possibility of 30 ordered items to be entered?

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would say use a multidimentional array.

    Array = ([ index1-->array(qty,number,item,price)], [index2-->array(qty,number,item,price) ...)

    If you items have a unique id, I'd suggest use that as the array index.

    Things might get complicated though...so just wait and see if someone has a better idea coz i'm not an expert. [img]images/smilies/smile.gif[/img]

  3. #3
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, there isn't a unique id # as this is part of a shopping cart... these are the ordered items... quantity,number,item,price

    Not sure of how to properly set up an array please explain with great detail and code if possible... thanks so much

  4. #4
    SitePoint Member
    Join Date
    Apr 2003
    Location
    interNET
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $data = array();
    for(
    $i=1$i<=30$i++) {
       
    $data[]=array(
                      
    'quantity'=$_REQUEST["quantity$i"],
                      
    'number'=$_REQUEST["number$i"],
                      
    'item'=$_REQUEST["item$i"],
                      
    'price'=$_REQUEST["price$i"]
                    )

    This will give you $data which has 30 rows every row has 4 columns like this:

    Code:
     $data = Array( 
                   [0] => Array(  
                                 [quantity] = ...
                                 [number] = ...
                                 [item] = ...
                                 [price] = ...
                         )
                    [1] => Array( 
                                 [quantity] = ...
                                 [number] = ...
                                 [item] = ...
                                 [price] = ...
                         )
    ...
    to access the 20th row's quantity for example: echo $data[19][quantity];

    then use ur ways to store them into DB or mail them.. or whatever

  5. #5
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the error that I'm getting while using VISUALMIND code.... error is line:
    PHP Code:
    205   $data[]=array( 
    ERROR=
    Parse error: parse error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site3/fst/var/www/html/secure/authnet/order_secure.php on line 205

  6. #6
    SitePoint Member
    Join Date
    Apr 2003
    Location
    interNET
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MAC#1
    This is the error that I'm getting while using VISUALMIND code.... error is line:
    PHP Code:
    205   $data[]=array( 
    ERROR=
    Parse error: parse error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site3/fst/var/www/html/secure/authnet/order_secure.php on line 205
    Weird! what's your php version?

    anyways, you can use this instead, and it should work:
    PHP Code:
       $data[$i]=array( 
    and that will make rows start with 1 instead of 0

  7. #7
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im using PHP 4.2.2

    Ok, tried that... thanks clears up that line but now error:

    Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site3/fst/var/www/html/secure/authnet/order_secure.php on line 206

  8. #8
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might want to eval the terms as key=>val should work whereas key=val within an associative array would try to assign

    PHP Code:
    $data = array();
    for(
    $i=1$i<=30$i++) {
       eval(
    "\$qua = \$_REQUEST['quantity" .$i"'];");
       eval(
    "\$itm = \$_REQUEST['item" .$i"'];");
       eval(
    "\$data[]=array('quantity'=>" .$qua",'item'=>" .$itm");");
       }
    var_dump($data); 
    add the other couple of lines yourself.
    teckis - that's news to me.

  9. #9
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow

    $data = array();
    for($i=1; $i<=30; $i++) {
    eval("\$qua = \$_REQUEST['quantity" .$i. "'];");
    eval("\$itm = \$_REQUEST['item" .$i. "'];");
    eval("\$data[]=array('quantity'=>" .$qua. ",'item'=>" .$itm. ");");
    }
    var_dump($data);

    I'm getting an error at the first eval string.. something todo with the \ .. not sure how to fix these two errors:
    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/virtual/site3/fst/var/www/html/secure/authnet/order_secure.php on line 205

    Parse error: parse error, unexpected T_VARIABLE in /home/virtual/site3/fst/var/www/html/secure/authnet/order_secure.php on line 205

  10. #10
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    // remove this bit - it just sets rand vals to all request vars for testing
    for($b 1$b 31$b++)
        {
        eval(
    "\$_REQUEST['quantity" .$b"'] = " .rand(0,1000). "; \$_REQUEST['number" .$b"'] = " .rand(0,1000). "; \$_REQUEST['item" .$b"'] = " .rand(0,1000). "; \$_REQUEST['price" .$b"'] = " .rand(0,1000). "; ");
        }
    var_dump($_REQUEST);
    // testing done

    $data_array = array();
    for(
    $c 1$c 31$c++)
        {
        eval(
    "\$data_array[] = array('quantity'=>" .$_REQUEST['quantity' .$c]. ",'number'=>" .$_REQUEST['number' .$c]. ",'item'=>" .$_REQUEST['item' .$c]. ",'price'=>" .$_REQUEST['price' .$c]. ");");
        }
    echo 
    '<br />-------------------------------<br />';
    var_dump($data_array);
    ?>
    tested and works
    teckis - that's news to me.

  11. #11
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MAC#1
    The following is only a snippet of 30 items that I need to have entered into a Mysql database and also sent through email. What is the proper procedure to set this into an array so that I can manipulate these items without having 30 rows of quantity/number/item/price in the database.

    Here is what I have:
    PHP Code:
    $quantity1=$_REQUEST["quantity1"]; 
    $number1=$_REQUEST["number1"]; 
    $item1=$_REQUEST["item1"]; 
    $price1=$_REQUEST["price1"];
    $quantity2=$_REQUEST["quantity2"]; 
    $number2=$_REQUEST["number2"]; 
    $item2=$_REQUEST["item2"]; 
    $price2=$_REQUEST["price2"]; //this continues til $blah30 (30 for each)

    // into email
    $quantity1 $number1 $item1 $price1
    $quantity2 $number2 $item2 $price2 
    // also til $blah30 
    How do I do an array so that I can just have a column for quantity, number, item allowing the possibility of 30 ordered items to be entered?
    Would this help?
    PHP Code:
    $totalOrder = array()
    $quantity   = array();
    $number     = array();
    $item       = array();
    $price      = array();
    $serializedQuantity '';
    $serializedNumber   '';
    $serializedItem     '';
    $serializedPrice    '';
    $emailBody    '';
    $elementCount 0;
    for( 
    $i 0$i 30$i++ )
    {
      if( 
    $_REQUEST["quantity".$i] )
      {
        
    $quantity[$elementCount] = $_REQUEST["quantity".$i];
        
    $number[$elementCount]   = $_REQUEST["number".$i];
        
    $item[$elementCount]     = $_REQUEST["item".$i];
        
    $price[$elementCount]    = $_REQUEST["price".$i];
        
        
    $serializedQuantity .= $quantity[$elementCount].',';
        
    $serializedNumber   .= $number[$elementCount].',';
        
    $serializedItem     .= $item[$elementCount].',';
        
    $serializedPrice    .= $price[$elementCount].',';
        
    $emailBody .= $quantity[$elementCount].' '.$number[$elementCount].' '.$item[$elementCount].' '.$price[$elementCount].'\n';
        
        
    $elementCount++;
      }
    }
    $serializedQuantity substr($serializedQuantity0strlen($serializedQuantity) - 1);
    $serializedNumber   substr($serializedNumber0strlen($serializedNumber) - 1);
    $serializedItem     substr($serializedItem0strlen($serializedItem) - 1);
    $serializedPrice    substr($serializedPrice0strlen($serializedPrice) - 1);
    //  Here is your single array
    $totalOrder = Array( $quantity$number$item$price );
    //  Insert into database the four fields of $serializedQuantity, $serializedNumber, $serializedItem, $serializedPrice here 
    Last edited by PHP John; May 12, 2003 at 00:57. Reason: code edit... can't use Java variables! 8)
    John

  12. #12
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    POOTERGEIST... not sure what to do with the results of this testing code... I'm assuming that if a random variable number is associated with each item .. that all is working?

    PHPJOHN... after trying your code this is the output:

    Array = Array( Array, Array, Array, Array );
    Last edited by MAC#1; May 12, 2003 at 06:52.

  13. #13
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mac, maybe you should be more clear about what you want to DO with this information, and how you tried to use the code I posted.

    WHAT do you want to use the arrays FOR, especially if you are going to store this information in a database.

    Why WOULDN't you want 30 rows with some identifying field in your table?

    Did you design the database?

    We are trying to help you on some very sketchy information.
    John

  14. #14
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHPJOHN... i appreciate the help immensely.

    The quantity,number,item and price are all part of a shopping cart system....

    the only reason that there are 30 of each is incase 30 items are ordered at one time... usually an order is only 1-5 items at most.

    Database is designed...
    Cust_Cart(posted,cart_id,cust_id,quantity,number,item,price)

    So, if I had an array that took each ordered item (quan,item,num,price) into one ITEM than it would save having 30 fields for each of the quantity, item, number, price.

    Please let me know what other information that I can supply to help you help me get this solved. (Im willing to pay some cash for your help)

  15. #15
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHPJOHN... I hadn't added the $serializedQuantity, $serializedNumber, $serializedItem, $serializedPrice. But now that I did it is now working... at least to an email!!! thanks so much ... now will try adding to the database :)

  16. #16
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a sample page I could see?
    John

  17. #17
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MAC#1
    PHPJOHN... I hadn't added the $serializedQuantity, $serializedNumber, $serializedItem, $serializedPrice. But now that I did it is now working... at least to an email!!! thanks so much ... now will try adding to the database [img]images/smilies/smile.gif[/img]
    Mac, if you want a slightly differnet format for your email, use the $emailBody variable that is built for you in the code for the (you guessed it!) email body.
    John

  18. #18
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by PHP John
    Do you have a sample page I could see?
    PHP Code:
    <?php
    // required variables
    require("config.php");

    $amount=$_REQUEST["amount"]; 
    $cart_id=$_REQUEST["cart_id"]; 
    $company=$_REQUEST["company"]; 
    $firstname=$_REQUEST["firstname"];
    $lastname=$_REQUEST["lastname"];  
    $email=$_REQUEST["email"]; 
    $address=$_REQUEST["address"]; 
    $city=$_REQUEST["city"]; 
    $state=$_REQUEST["state"]; 
    $zip=$_REQUEST["zip"]; 
    $country=$_REQUEST["country"]; 
    $phone=$_REQUEST["phone"]; 
    $comment=$_REQUEST["comment"]; 
    $total=$_REQUEST["total"]; 
    $order_id=$_REQUEST["cart_id"]; 

    $quantity1=$_REQUEST['quantity1']; 
    $number1=$_REQUEST['number1']; 
    $item1=$_REQUEST['item1']; 
    $price1=$_REQUEST['price1'];
    $option1=$_REQUEST["option1"]; 
    $quantity2=$_REQUEST['quantity2']; 
    $number2=$_REQUEST['number2']; 
    $item2=$_REQUEST['item2'];  
    $price2=$_REQUEST['price2'];
    $option2=$_REQUEST["option2"];
    $quantity3=$_REQUEST["quantity3"]; 
    $number3=$_REQUEST["number3"];
    $item3=$_REQUEST["item3"]; 
    $price3=$_REQUEST["price3"];
    $option3=$_REQUEST["option3"];
    $quantity4=$_REQUEST["quantity4"]; 
    $number4=$_REQUEST["number4"]; 
    $item4=$_REQUEST["item4"]; 
    $price4=$_REQUEST["price4"];
    $option4=$_REQUEST["option4"];
    $quantity5=$_REQUEST["quantity5"]; 
    $number5=$_REQUEST["number5"]; 
    $item5=$_REQUEST["item5"]; 
    $price5=$_REQUEST["price5"];
    $option5=$_REQUEST["option5"];
    $quantity6=$_REQUEST["quantity6"]; 
    $number6=$_REQUEST["number6"]; 
    $item6=$_REQUEST["item6"]; 
    $price6=$_REQUEST["price6"];
    $option6=$_REQUEST["option6"];
    $quantity7=$_REQUEST["quantity7"]; 
    $number7=$_REQUEST["number7"]; 
    $item7=$_REQUEST["item7"]; 
    $price7=$_REQUEST["price7"];
    $option7=$_REQUEST["option7"];
    $quantity8=$_REQUEST["quantity8"]; 
    $number8=$_REQUEST["number8"];
    $item8=$_REQUEST["item8"]; 
    $price8=$_REQUEST["price8"];
    $option8=$_REQUEST["option8"];
    $quantity9=$_REQUEST["quantity9"]; 
    $number9=$_REQUEST["number9"]; 
    $item9=$_REQUEST["item9"]; 
    $price9=$_REQUEST["price9"];
    $option9=$_REQUEST["option9"];
    $quantity10=$_REQUEST["quantity10"]; 
    $number10=$_REQUEST["number10"]; 
    $item10=$_REQUEST["item10"]; 
    $price10=$_REQUEST["price10"];
    $option10=$_REQUEST["option10"];

    $quantity11=$_REQUEST["quantity11"]; 
    $number11=$_REQUEST["number11"]; 
    $item11=$_REQUEST["item11"]; 
    $price11=$_REQUEST["price11"];
    $option11=$_REQUEST["option11"]; 
    $quantity12=$_REQUEST["quantity12"]; 
    $number12=$_REQUEST["number12"]; 
    $item12=$_REQUEST["item12"];  
    $price12=$_REQUEST["price12"];
    $option12=$_REQUEST["option12"];
    $quantity13=$_REQUEST["quantity13"]; 
    $number13=$_REQUEST["number3"];
    $item13=$_REQUEST["item13"]; 
    $price13=$_REQUEST["price13"];
    $option13=$_REQUEST["option13"];
    $quantity14=$_REQUEST["quantity14"]; 
    $number14=$_REQUEST["number4"]; 
    $item14=$_REQUEST["item14"]; 
    $price14=$_REQUEST["price14"];
    $option14=$_REQUEST["option14"];
    $quantity15=$_REQUEST["quantity15"]; 
    $number15=$_REQUEST["number15"]; 
    $item15=$_REQUEST["item15"]; 
    $price15=$_REQUEST["price15"];
    $option15=$_REQUEST["option15"];
    $quantity16=$_REQUEST["quantity16"]; 
    $number16=$_REQUEST["number16"]; 
    $item16=$_REQUEST["item16"]; 
    $price16=$_REQUEST["price16"];
    $option16=$_REQUEST["option16"];
    $quantity17=$_REQUEST["quantity17"]; 
    $number17=$_REQUEST["number17"]; 
    $item17=$_REQUEST["item17"]; 
    $price17=$_REQUEST["price17"];
    $option17=$_REQUEST["option17"];
    $quantity18=$_REQUEST["quantity18"]; 
    $number18=$_REQUEST["number18"];
    $item18=$_REQUEST["item18"]; 
    $price18=$_REQUEST["price18"];
    $option18=$_REQUEST["option18"];
    $quantity19=$_REQUEST["quantity19"]; 
    $number19=$_REQUEST["number19"]; 
    $item19=$_REQUEST["item19"]; 
    $price19=$_REQUEST["price19"];
    $option19=$_REQUEST["option19"];
    $quantity20=$_REQUEST["quantity20"]; 
    $number20=$_REQUEST["number20"]; 
    $item20=$_REQUEST["item20"]; 
    $price20=$_REQUEST["price20"];
    $option20=$_REQUEST["option20"];

    $quantity21=$_REQUEST["quantity21"]; 
    $number21=$_REQUEST["number21"]; 
    $item21=$_REQUEST["item21"]; 
    $price21=$_REQUEST["price21"];
    $option21=$_REQUEST["option21"]; 
    $quantity22=$_REQUEST["quantity22"]; 
    $number22=$_REQUEST["number22"]; 
    $item22=$_REQUEST["item22"];  
    $price22=$_REQUEST["price22"];
    $option22=$_REQUEST["option22"];
    $quantity23=$_REQUEST["quantity23"]; 
    $number23=$_REQUEST["number23"];
    $item23=$_REQUEST["item23"]; 
    $price23=$_REQUEST["price23"];
    $option23=$_REQUEST["option23"];
    $quantity24=$_REQUEST["quantity24"]; 
    $number24=$_REQUEST["number24"]; 
    $item24=$_REQUEST["item24"]; 
    $price24=$_REQUEST["price24"];
    $option24=$_REQUEST["option24"];
    $quantity25=$_REQUEST["quantity25"]; 
    $number25=$_REQUEST["number25"]; 
    $item25=$_REQUEST["item25"]; 
    $price25=$_REQUEST["price25"];
    $option25=$_REQUEST["option25"];
    $quantity26=$_REQUEST["quantity26"]; 
    $number26=$_REQUEST["number26"]; 
    $item26=$_REQUEST["item26"]; 
    $price26=$_REQUEST["price26"];
    $option26=$_REQUEST["option26"];
    $quantity27=$_REQUEST["quantity27"]; 
    $number27=$_REQUEST["number27"]; 
    $item27=$_REQUEST["item27"]; 
    $price27=$_REQUEST["price27"];
    $option27=$_REQUEST["option27"];
    $quantity28=$_REQUEST["quantity28"]; 
    $number28=$_REQUEST["number28"];
    $item28=$_REQUEST["item28"]; 
    $price28=$_REQUEST["price28"];
    $option28=$_REQUEST["option28"];
    $quantity29=$_REQUEST["quantity29"]; 
    $number29=$_REQUEST["number29"]; 
    $item29=$_REQUEST["item29"]; 
    $price29=$_REQUEST["price29"];
    $option29=$_REQUEST["option29"];
    $quantity30=$_REQUEST["quantity30"]; 
    $number30=$_REQUEST["number30"]; 
    $item30=$_REQUEST["item30"]; 
    $price30=$_REQUEST["price30"];
    $option30=$_REQUEST["option30"];

    $totalOrder = array();
    $quantity   = array();
    $number     = array();
    $item       = array();
    $price      = array();
    $serializedQuantity '';
    $serializedNumber   '';
    $serializedItem     '';
    $serializedPrice    '';
    $emailBody    '';
    $elementCount 0;
    for( 
    $i 0$i 30$i++ )
    {
      if( 
    $_REQUEST["quantity".$i] )
      {
        
    $quantity[$elementCount] = $_REQUEST["quantity".$i];
        
    $number[$elementCount]   = $_REQUEST["number".$i];
        
    $item[$elementCount]     = $_REQUEST["item".$i];
        
    $price[$elementCount]    = $_REQUEST["price".$i];
        
        
    $serializedQuantity .= $quantity[$elementCount].',';
        
    $serializedNumber   .= $number[$elementCount].',';
        
    $serializedItem     .= $item[$elementCount].',';
        
    $serializedPrice    .= $price[$elementCount].',';
        
    $emailBody .= $quantity[$elementCount].' '.$number[$elementCount].' '.$item[$elementCount].' '.$price[$elementCount].'\n';
        
        
    $elementCount++;
      }
    }
    $serializedQuantity substr($serializedQuantity0strlen($serializedQuantity) - 1);
    $serializedNumber   substr($serializedNumber0strlen($serializedNumber) - 1);
    $serializedItem     substr($serializedItem0strlen($serializedItem) - 1);
    $serializedPrice    substr($serializedPrice0strlen($serializedPrice) - 1);
    //  Here is your single array
    $totalOrder = Array( $quantity$number$item$price );
    //  Insert into database the four fields of $serializedQuantity, $serializedNumber, $serializedItem, $serializedPrice here 



    // generates cart id number 
    $cart_id date("ymjHis");

    // generates cart id number 
    $posted date("Y-m-d");


    $message ="IP: $REMOTE_ADDR
    Thank you for placing your order: ART-SEW-PERFECT'S ONLINE

    Credit Card - Order Number 
    $cart_id

    Email -
    $email
    Company - 
    $company
    Firstname - 
    $firstname
    LastName - 
    $lastname
    Address - 
    $address 
    City - 
    $city
    State -
    $state
    Zip - 
    $zip
    Country - 
    $country
    Phone - 
    $phone

    Comment: 
    $comment

    Total 
    $txt_currency:  $total

    Order: 
    $serializedQuantity$serializedNumber$serializedItem$serializedPrice 

    "
    ;       
    mail("$receipt2""Re: Online Order""$message""From:$receipt"); 

    // database connection
    mysql_connect("$host","$user","$pass");

    // database selection
    mysql_select_db($database);
    mysql_query("insert into card_payment values('$posted', '$cust_id', '$cart_id','$total')");
    mysql_query("insert into cust_order values('$posted', '$order_id', '$cust_id', '$company','$firstname', '$lastname','$address', '$city','$state','$zip','$country','$phone', '$email', '$password')");
    mysql_query("insert into cust_cart values('$posted', '$cart_id', '$cust_id', '$serializedQuantity', $serializedNumber, '$serializedItem', '$serializedPrice')");

    ?>


    <html>

    <head>

    <title>Credit Card Payment</title>

    <style>

    A:Link {color:000000;text-decoration:none;}

    A:Visited {color:000000;text-decoration:none;}

    A:Hover {color:F70404;}

    </style>

    </head>

    <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#660101" VLINK="#660101" ALINK="#F70404">
            
    <script LANGUAGE="JavaScript">

        function resetShoppingBasket() {
            index = document.cookie.indexOf("TheBasket");
            document.cookie="TheBasket=.";
        }

    </script>

    <script language="JavaScript">

    resetShoppingBasket()

    top.frames[2].location = "middle_right.php";

    </script>
    <div align="center">
    <form onsubmit="return form_validator(this)" action="https://secure.artsewperfect.com/secure/authnet/process.php" method=post>
                    <script language="JavaScript"><!-- //script hider
    function form_validator(theForm)
    {

            if(theForm.firstname.value == "") {
             alert("<?php echo $txt_missing_firstname ?>");
             theForm.firstname.focus();
             return(false);
        }

        if(theForm.lastname.value == "") {
             alert("<?php echo $txt_missing_lastname ?>");
             theForm.lastname.focus();
             return(false);
        }
        
        if(theForm.address.value == "") {
             alert("<?php echo $txt_missing_address ?>");
             theForm.address.focus();
             return(false);
        }

        if(theForm.city.value == "") {
             alert("<?php echo $txt_missing_city ?>!");
             theForm.city.focus();
             return(false);
        }

        if(theForm.zip.value == "") {
             alert("<?php echo $txt_missing_zip ?>!");
             theForm.zip.focus();
             return(false);
        }

        if(theForm.state.value == "") {
             alert("<?php echo $txt_missing_state ?>!");
             theForm.state.focus();
             return(false);
        }

        if(theForm.country.value == "") {
             alert("<?php echo $txt_missing_country ?>!");
             theForm.country.focus();
             return(false);
        }

        if(theForm.phone.value == "") {
             alert("<?php echo $txt_missing_phone ?>");
             theForm.phone.focus();
             return(false);
        }

        if(theForm.cardnum.value == "") {
             alert("<?php echo $txt_missing_credit_card ?>!");
             theForm.cardnum.focus();
             return(false);
        }

              if (!(theForm.expmo.selectedIndex)) {
            alert('<?php echo $txt_missing_expmo ?>');
            event.returnValue=false;
        }

              if (!(theForm.expyr.selectedIndex)) {
            alert('<?php echo $txt_missing_expyr ?>');
            event.returnValue=false;
        }



        return (true);
    }
    // end script hiding --></script>


                    <input type="hidden" name="total" value="<?php echo $total?>"> <input type="hidden" name="amount" value="<?php echo $amount?>"> <input type="hidden" name="cart_id" value="<?php echo $cart_id?>">
                    <center>
                        <font size="5" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_credit_card_payment?></b></font></center>
                    <hr width=75% size=1 color="#000000">
                    <div align="center">
                        <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $step2?></b> <?php echo $txt_credit_card_info?>
                        <p><b>Order Number:</b> <?php echo $cart_id?> <b><?php echo $txt_amount?>&nbsp;<?php echo $txt_currency ?>:</b> <?php echo $total ?></FONT></p>
                    </div>
                    <center>
                        <br>
                        <table cellpadding="2" cellspacing="1" border="0">
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_company ?></b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name="company" value="<?php echo $company ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_firstname ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=firstname value="<?php echo $firstname ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_lastname ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=lastname value="<?php echo $lastname ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_address ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=address value="<?php echo $address ?>" size=40></td>
                            </tr>
                            
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_city ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=city value="<?php echo $city ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_state_province ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=state value="<?php echo $state ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_zip ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=zip value="<?php echo $zip ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_country ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=country value="<?php echo $country ?>" size=40></td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_phone ?> *</b></font></td>
                                <td bgcolor="#D9D9D9"><input type=text name=phone value="<?php echo $phone?>" size=20></td>
                            </tr>
                            <tr bgcolor="#D9D9D9">
                                <td colspan=2 align=center><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_payment_method?></b></font>
                                    <table border=0 bgcolor="#D9D9D9">
                                        <tr>
                                            <td valign=top><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input type=radio name="payment_method" value="Visa"> <b>Visa</b></font></td>
                                            <td valign=top><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input type=radio name="payment_method" value="Mastercard"> <b>Mastercard</b></font></td>
                                        </tr>
                                    </table>
                                    <table border=0 bgcolor="#D9D9D9">
                                        <tr>
                                            <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Credit Card</b></font></td>
                                            <td><input type=text name="ccnumber" maxlength="150" size="30"></td>
                                        </tr>
                                        <tr>
                                            <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Exp. Date</b></font></td>
                                            <td><select name="expmo">
                                                    <option></option>
                                                    <option>01</option>
                                                    <option>02</option>
                                                    <option>03</option>
                                                    <option>04</option>
                                                    <option>05</option>
                                                    <option>06</option>
                                                    <option>07</option>
                                                    <option>08</option>
                                                    <option>09</option>
                                                    <option>10</option>
                                                    <option>11</option>
                                                    <option>12 </option>
                                                </select> <select name="expyr">
                                                    <option></option>
                                                    <option>2001</option>
                                                    <option>2002</option>
                                                    <option>2003</option>
                                                    <option>2004</option>
                                                    <option>2005</option>
                                                    <option>2006</option>
                                                    <option>2007</option>
                                                    <option>2008</option>
                                                    <option>2009</option>
                                                    <option>2010</option>
                                                    <option>2011 </option>
                                                </select></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align=center colspan=2><input type=submit name=Submit value="<?php echo $txt_submit ?>" style="font-family: Verdana, Geneva, Helvetica; font-weight: regular; font-style: regular; font-size: 10px; color: #000000; height:20px"> <input type=reset value="<?php echo $txt_reset ?>" style="font-family: Verdana, Geneva, Helvetica; font-weight: regular; font-style: regular; font-size: 10px; color: #000000; height:20px"></td>
                            </tr>
                        </table>
                        </FONT></center>
                    

                
                    <input type=HIDDEN name="amount" value="<?php echo $total?>"> 
                    <input type=HIDDEN name="cust_id" value="<?php echo $cart_id?>"> 
                    <input type=HIDDEN name="x_Description" value="Payment for Order Number <?php echo $cart_id?>"> 
                    <input type=HIDDEN name="x_Invoice_Num" value="<?php echo $cart_id?>">
                    <input type=HIDDEN name="company" value="<?php echo $company?>"> 
                    <input type=HIDDEN name="x_First_Name" value="<?php echo $firstname?>">
                    <input type=HIDDEN name="x_Last_Name" value="<?php echo $lastname?>"> 
                    <input type=HIDDEN name="email" value="<?php echo $email?>"> 
                    <input type=HIDDEN name="x_Address" value="<?php echo $address?>"> 
                    <input type=HIDDEN name="x_City" value="<?php echo $city?>"> 
                    <input type=HIDDEN name="x_State" value="<?php echo $state?>"> 
                    <input type=HIDDEN name="x_Zip" value="<?php echo $zip?>"> 
                    <input type=HIDDEN name="x_Country" value="<?php echo $country?>"> 
                    <input type=HIDDEN name="x_Phone" value="<?php echo $phone?>"> 
                    <input type=HIDDEN name="x_Comment" value="<?php echo $comment?>">
                    <input type=HIDDEN name="order_id" value="<?php echo $cart_id?>">

                
                </form>
        <?php echo $quantity ?>
        <?php echo $item ?>
        <?php echo $price?>
        
                <img src="../../stauthnet/secure/images/authorizenet.gif" width="117" height="32" alt="Authorize.net"></div>
        </BODY>
    </HTML>
    ----------------------
    Currently getting each field together when more than one item is ordered (formatting in email):ex. 1,1,0003,0004,sea shells,rocks,49.95,49.95
    instead of:
    1, 0003, sea shells, 49.95
    1, 0004, rocks, 49.95
    .... I'm not sure how to fix this formatting.

  19. #19
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the $emailBody variable in place of the serialized variables.
    John

  20. #20
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see where you are generating the $cust_id value. Could you point it out?
    John

  21. #21
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright... I went through the code and changed a few things.

    Something you need to understand is that databases are designed to handle large quantities of information. Having 30 rows of order information per customer order is nothing new. And storing it in such a way makes maintenance easier, and gives you more data manipulation options with less code.

    Here is the revised code that inserts each order item as a new row in your database. If you really don't want it that way, tell me and I can easily replace that code with the "one order per row" code.

    The other concern I have is that I could not find where the $cust_id variable was assigned a value.

    If I could offer some further advise, extend your <styles> to the table background and the font color and size. This will clean up your code greatly, and lower your maintenance time.

    PHP Code:
    <?php 
    // required variables 
    require("config.php" ); 
    $amount     $_REQUEST["amount"]; 
    $cart_id    $_REQUEST["cart_id"]; 
    $company    $_REQUEST["company"]; 
    $firstname  $_REQUEST["firstname"]; 
    $lastname   $_REQUEST["lastname"];   
    $email      $_REQUEST["email"]; 
    $address    $_REQUEST["address"]; 
    $city       $_REQUEST["city"]; 
    $state      $_REQUEST["state"]; 
    $zip        $_REQUEST["zip"]; 
    $country    $_REQUEST["country"]; 
    $phone      $_REQUEST["phone"]; 
    $comment    $_REQUEST["comment"]; 
    $total      $_REQUEST["total"]; 
    $order_id   $_REQUEST["cart_id"]; 
    // generates cart id number 
    $cart_id date("ymjHis" ); 
    // generates cart id number 
    $posted date("Y-m-d" ); 
    $emailBody '';
    // database connection 
    mysql_connect("$host","$user","$pass); 
    // database selection 
    mysql_select_db($database); 
    //  Insert payment
    mysql_query("INSERT INTO card_payment VALUES(
                  '
    $posted',
                  '
    $cust_id',
                  '
    $cart_id',
                  '
    $total')" ); 
                  
    //  Insert customer information
    mysql_query("INSERT INTO cust_order VALUES(
                  '
    $posted',
                  '
    $order_id',
                  '
    $cust_id',
                  '
    $company',
                  '
    $firstname',
                  '
    $lastname',
                  '
    $address',
                  '
    $city',
                  '
    $state',
                  '
    $zip',
                  '
    $country',
                  '
    $phone',
                  '
    $email',
                  '
    $password')" ); 
    for( 
    $i 0$i 30$i++ )
    {
      if( 
    $_REQUEST["quantity".$i] )
      {
        
        
    // Build the body of the email:
        // The format is:
        // [quantity] [number] [item] [price]   
        // [quantity] [number] [item] [price]
        // [quantity] [number] [item] [price]
        // etc...
        
        
    $emailBody .= $_REQUEST["quantity".$i].', '.$_REQUEST["number".$i].', '.$_REQUEST["item".$i].', '.$_REQUEST["price".$i].'\n';     
        
        
    // Build the query for each item and insert it into the database
        
        
    mysql_query"INSERT INTO Cust_cart
                      SET
                        posted    = '
    $posted',
                        cart_id   = '
    $cart_id',
                        cust_id   = '
    $cust_id',
                        quanitity = "
    .$_REQUEST["quanitity".$i].",
                        number    = "
    .$_REQUEST["number".$i].",
                        item      = '"
    .$_REQUEST["item".$i]."',
                        price     = "
    .$_REQUEST["price".$i] );
      }    
    }
    $message ="IP: $REMOTE_ADDR Thank you for placing your order: ART-SEW-PERFECT'S ONLINE 
    Credit Card - Order Number 
    $cart_id 
    Email -
    $email 
    Company - 
    $company 
    Firstname - 
    $firstname 
    LastName - 
    $lastname 
    Address - 
    $address 
    City - 
    $city 
    State -
    $state 
    Zip - 
    $zip 
    Country - 
    $country 
    Phone - 
    $phone 
    Comment: 
    $comment 
    Total 
    $txt_currency:  $total 
    Order: 
    $emailBody
    "
    ;        
    mail("$receipt2""Re: Online Order""$message""From:$receipt); 
    ?> 

    <html> 
    <head> 
    <title>Credit Card Payment</title> 
    <style> 
    A:Link {color:000000;text-decoration:none;} 
    A:Visited {color:000000;text-decoration:none;} 
    A:Hover {color:F70404;} 
    </style> 
    </head> 
    <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#660101" VLINK="#660101" ALINK="#F70404"> 
             
    <script LANGUAGE="JavaScript"> 
        function resetShoppingBasket() { 
            index = document.cookie.indexOf("TheBasket" ); 
            document.cookie="TheBasket=."; 
        } 
    </script> 
    <script language="JavaScript"> 
    resetShoppingBasket() 
    top.frames[2].location = "middle_right.php"; 
    </script> 
    <div align="center"> 
    <form onsubmit="return form_validator(this)" action="[url=https://secure.artsewperfect.com/secure/authnet/process.php]https://secure.artsewperfect.com/secure/authnet/process.php[/url]" method=post> 
                    <script language="JavaScript"><!-- //script hider 
    function form_validator(theForm) 

            if(theForm.firstname.value == "" ) { 
             alert("<?php echo $txt_missing_firstname ?>" ); 
             theForm.firstname.focus(); 
             return(false); 
        } 
        if(theForm.lastname.value == "" ) { 
             alert("<?php echo $txt_missing_lastname ?>" ); 
             theForm.lastname.focus(); 
             return(false); 
        } 
         
        if(theForm.address.value == "" ) { 
             alert("<?php echo $txt_missing_address ?>" ); 
             theForm.address.focus(); 
             return(false); 
        } 
        if(theForm.city.value == "" ) { 
             alert("<?php echo $txt_missing_city ?>!" ); 
             theForm.city.focus(); 
             return(false); 
        } 
        if(theForm.zip.value == "" ) { 
             alert("<?php echo $txt_missing_zip ?>!" ); 
             theForm.zip.focus(); 
             return(false); 
        } 
        if(theForm.state.value == "" ) { 
             alert("<?php echo $txt_missing_state ?>!" ); 
             theForm.state.focus(); 
             return(false); 
        } 
        if(theForm.country.value == "" ) { 
             alert("<?php echo $txt_missing_country ?>!" ); 
             theForm.country.focus(); 
             return(false); 
        } 
        if(theForm.phone.value == "" ) { 
             alert("<?php echo $txt_missing_phone ?>" ); 
             theForm.phone.focus(); 
             return(false); 
        } 
        if(theForm.cardnum.value == "" ) { 
             alert("<?php echo $txt_missing_credit_card ?>!" ); 
             theForm.cardnum.focus(); 
             return(false); 
        } 
              if (!(theForm.expmo.selectedIndex)) { 
            alert('<?php echo $txt_missing_expmo ?>'); 
            event.returnValue=false; 
        } 
              if (!(theForm.expyr.selectedIndex)) { 
            alert('<?php echo $txt_missing_expyr ?>'); 
            event.returnValue=false; 
        } 
     
        return (true); 

    // end script hiding --></script> 

                    <input type="hidden" name="total" value="<?php echo $total?>"> <input type="hidden" name="amount" value="<?php echo $amount?>"> <input type="hidden" name="cart_id" value="<?php echo $cart_id?>"> 
                    <center> 
                        <font size="5" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_credit_card_payment?></b></font></center> 
                    <hr width=75% size=1 color="#000000"> 
                    <div align="center"> 
                        <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $step2?></b> <?php echo $txt_credit_card_info?> 
                        <p><b>Order Number:</b> <?php echo $cart_id?> <b><?php echo $txt_amount?>&nbsp;<?php echo $txt_currency ?>:</b> <?php echo $total ?></FONT></p> 
                    </div> 
                    <center> 
                        <br> 
                        <table cellpadding="2" cellspacing="1" border="0"> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_company ?></b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name="company" value="<?php echo $company ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_firstname ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=firstname value="<?php echo $firstname ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_lastname ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=lastname value="<?php echo $lastname ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_address ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=address value="<?php echo $address ?>" size=40></td> 
                            </tr> 
                             
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_city ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=city value="<?php echo $city ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_state_province ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=state value="<?php echo $state ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_zip ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=zip value="<?php echo $zip ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_country ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=country value="<?php echo $country ?>" size=40></td> 
                            </tr> 
                            <tr> 
                                <td bgcolor="#D9D9D9"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_phone ?> *</b></font></td> 
                                <td bgcolor="#D9D9D9"><input type=text name=phone value="<?php echo $phone?>" size=20></td> 
                            </tr> 
                            <tr bgcolor="#D9D9D9"> 
                                <td colspan=2 align=center><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_payment_method?></b></font> 
                                    <table border=0 bgcolor="#D9D9D9"> 
                                        <tr> 
                                            <td valign=top><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input type=radio name="payment_method" value="Visa"> <b>Visa</b></font></td> 
                                            <td valign=top><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input type=radio name="payment_method" value="Mastercard"> <b>Mastercard</b></font></td> 
                                        </tr> 
                                    </table> 
                                    <table border=0 bgcolor="#D9D9D9"> 
                                        <tr> 
                                            <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Credit Card</b></font></td> 
                                            <td><input type=text name="ccnumber" maxlength="150" size="30"></td> 
                                        </tr> 
                                        <tr> 
                                            <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Exp. Date</b></font></td> 
                                            <td><select name="expmo"> 
                                                    <option></option> 
                                                    <option>01</option> 
                                                    <option>02</option> 
                                                    <option>03</option> 
                                                    <option>04</option> 
                                                    <option>05</option> 
                                                    <option>06</option> 
                                                    <option>07</option> 
                                                    <option>08</option> 
                                                    <option>09</option> 
                                                    <option>10</option> 
                                                    <option>11</option> 
                                                    <option>12</option> 
                                                </select> <select name="expyr"> 
                                                    <option></option> 
                                                    <option>2001</option> 
                                                    <option>2002</option> 
                                                    <option>2003</option> 
                                                    <option>2004</option> 
                                                    <option>2005</option> 
                                                    <option>2006</option> 
                                                    <option>2007</option> 
                                                    <option>2008</option> 
                                                    <option>2009</option> 
                                                    <option>2010</option> 
                                                    <option>2011</option> 
                                                </select></td> 
                                        </tr> 
                                    </table> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td align=center colspan=2><input type=submit name=Submit value="<?php echo $txt_submit ?>" style="font-family: Verdana, Geneva, Helvetica; font-weight: regular; font-style: regular; font-size: 10px; color: #000000; height:20px"> <input type=reset value="<?php echo $txt_reset ?>" style="font-family: Verdana, Geneva, Helvetica; font-weight: regular; font-style: regular; font-size: 10px; color: #000000; height:20px"></td> 
                            </tr> 
                        </table> 
                        </FONT></center> 
                     
                 
                    <input type=HIDDEN name="amount" value="<?php echo $total?>"> 
                    <input type=HIDDEN name="cust_id" value="<?php echo $cart_id?>"> 
                    <input type=HIDDEN name="x_Description" value="Payment for Order Number <?php echo $cart_id?>"> 
                    <input type=HIDDEN name="x_Invoice_Num" value="<?php echo $cart_id?>"> 
                    <input type=HIDDEN name="company" value="<?php echo $company?>"> 
                    <input type=HIDDEN name="x_First_Name" value="<?php echo $firstname?>"> 
                    <input type=HIDDEN name="x_Last_Name" value="<?php echo $lastname?>"> 
                    <input type=HIDDEN name="email" value="<?php echo $email?>"> 
                    <input type=HIDDEN name="x_Address" value="<?php echo $address?>"> 
                    <input type=HIDDEN name="x_City" value="<?php echo $city?>"> 
                    <input type=HIDDEN name="x_State" value="<?php echo $state?>"> 
                    <input type=HIDDEN name="x_Zip" value="<?php echo $zip?>"> 
                    <input type=HIDDEN name="x_Country" value="<?php echo $country?>"> 
                    <input type=HIDDEN name="x_Phone" value="<?php echo $phone?>"> 
                    <input type=HIDDEN name="x_Comment" value="<?php echo $comment?>"> 
                    <input type=HIDDEN name="order_id" value="<?php echo $cart_id?>"> 
                 
                </form> 
        <?php echo $quantity ?> 
        <?php echo $item ?> 
        <?php echo $price?> 
         
                <img src="../../stauthnet/secure/images/authorizenet.gif" width="117" height="32" alt="Authorize.net"></div> 
        </BODY> 
    </HTML>
    John

  22. #22
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHPJOHN... thanks for all that code.
    I'm getting a blank response page other than this text: https://secure.artsewperfect.com/se...net/process.php" method=post>

    also.. i am not sure why this is needed??
    PHP Code:
    <form onsubmit="return form_validator(this)" action="<a href=\"https://secure.artsewperfect.com/secure/authnet/process.php\" target=\"_blank\">https://secure.artsewperfect.com/se...net/process.php</a>" method=post

  23. #23
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That code you have there is the BBS software screwing with the code I posted. Restore that line with your original line. If that is confusing, let me know.
    John

  24. #24
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Quote Originally Posted by PHP John
    I don't see where you are generating the $cust_id value. Could you point it out?
    $cust_id is not part of the original code.. I was going to work on that once I got the crucial ordered items into the email and db. I would be curious to know how you would specify a customer id? Is there a built-in function that PHP would create the customer id?

    thanks greatly for ALL your help PHPJOHN... please send me a pm if you would like to receive a small compensation for all your help. thanks.

  25. #25
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So does it work?

    To create a unique id for your customers, I would require them to register as a user of the site. You already have the customer table, add a field "cust_id PRIMARY KEY AUTO_INCREMENT"

    Set a cookie ( not always reliable ), and the retrieve it to populate the shipping and billing information from the database info. If the cookie retrieval does not work, require them to log in. Use the log in to retrieve the data from the database and populate the shipping and biling fields.
    Last edited by PHP John; May 12, 2003 at 19:57.
    John


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
  •