Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19223 > unrolled thread

JSON and PHP

Started bydoctor@doctor.nl2k.ab.ca (The Doctor)
First post2022-12-28 00:34 +0000
Last post2022-12-28 21:28 -0800
Articles 8 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  JSON and PHP doctor@doctor.nl2k.ab.ca (The Doctor) - 2022-12-28 00:34 +0000
    Re: JSON and PHP "J.O. Aho" <user@example.net> - 2022-12-28 09:56 +0100
      Re: JSON and PHP doctor@doctor.nl2k.ab.ca (The Doctor) - 2022-12-28 14:42 +0000
        Re: JSON and PHP "J.O. Aho" <user@example.net> - 2022-12-28 22:09 +0100
          Re: JSON and PHP H H H H H H H H H H H H H H H H H H E <angel00000100000@icloud.com> - 2023-01-04 09:10 -0800
            Stop spamming (Was: JSON and PHP) "J.O. Aho" <user@example.net> - 2023-01-04 19:24 +0100
    Re: JSON and PHP Arno Welzel <usenet@arnowelzel.de> - 2022-12-28 19:00 +0100
    Re: JSON and PHP ThE sUn <angel00000100000@mail.ee> - 2022-12-28 21:28 -0800

#19223 — JSON and PHP

Fromdoctor@doctor.nl2k.ab.ca (The Doctor)
Date2022-12-28 00:34 +0000
SubjectJSON and PHP
Message-ID<tog2vc$tnl$21@gallifrey.nk.ca>
Trying to implement a JSON array in PHP


Using


<?=session_start();
error_reporting(E_ALL);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
<link rel="stylesheet" type="text/css" href="css/css.css"/>
<link rel="stylesheet" type="text/css" href="css/css2.css"/>
    <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/uniform.agent.css" type="text/css" media="screen">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<?php 
 if(!empty($_SESSION['sessiondata'])){
 }
?>
<div id="wrapper">
 <!--header begins-->
 <?php
  include("includes/header.php");
 ?> 
<!--header ends-->
<FORM ACTION="https://gatewayt.moneris.com/chkt/request/request.php" method=post>
<div id="outerDiv" style="width:400px"; height"300px">`
<div id="monerisCheckout"></div></div>
<script src="https://gatewayt.moneris.com/chkt/js/chkt_v1.00.js"></script>
<script>
var myCheckout = new monerisCheckout();
myCheckout.setMode("qa");
myCheckout.setCheckoutDiv("monerisCheckout");
myCheckout.setCheckout([ticket #]);
myCheckout.setCallback("page_loaded", myPageLoad);
myCheckout.setCallback("cancel_transaction", myCancelTransaction);
myCheckout.setCallback("error_event", myErrorEvent);
myCheckout.setCallback("payment_receipt", myPaymentReceipt);
myCheckout.setCallback("payment_complete", myPaymentComplete);
</script>
<?php 

?>
<center>
<!-- Store Settings-->
<INPUT TYPE="HIDDEN" NAME="ps_store_id" VALUE="<?=$myObj->store_id?>">
<INPUT TYPE="HIDDEN" NAME="checkout_id" VALUE="<?=$myObj->checkout_id?>">
<!------- DEFINE CHARGE TOTAL HERE --->
<br/><br/><h3>Your Purchase Total Is: </h3> <br/> <h2>$<?=$myObj->txn_total?></h2> 
<INPUT TYPE="hidden" NAME="charge_total" VALUE="<?=$myObj->txn_total?>"><br><br>
<!-- Unique Order ID -->
<!--INPUT TYPE="hidden" NAME="order_id" VALUE="<?=$myObj->sessValue?>"-->
<!-- Additional Optional Details -->
<input type="hidden" name="cust_id" value="<?=$MyObj->sessValue?>">
<input type="hidden" name="email" value="<?=$myObj->email?>">
<input type="hidden" name="note" value="">
<!-- Item Information -->
<?php 

$items_count = 1;
$subtotal = 0;
$arr = array();
foreach ($_POST['quantity'] as $key => $value) {

  if( $value > 0){

    if(isset($_POST['with_gst'][$key])){
      $unit_cost = 63.00;
    }else{
      $unit_cost = 60.00; //no gst included
    }

    $subtotal = ($unit_cost * $value);
    $quantity = ($value);
    

    ?>
      <input name="quantity<?=$items_count?>" value="<?=$quantity?>">
      <input name="description<?=$items_count?>" value="<?=$_POST['description'][$key]?>">
      <input name="id<?=$items_count?>" value="<?=$_POST['id'][$key]?>">
      <input name="price<?=$items_count?>" value="<?=$unit_cost?>">
      <input name="subtotal<?=$items_count?>" value="<?=$subtotal?>">
    <?php
$myObj = [];
if (isset($_POST["submit"])){
(array_push($myObj,[
'sessValue' =>[ $_POST['sessionid1']],
'username'=> ["demouser"],
'password' => ["password"],
'store_id' => ["store3"],
'checkout_id' => ["chkt23NGFtore3"],
'api_token' => ["yesguy"],
'txn_total' => [$_POST['charge_total']],

'bill_first_name' =>[$_POST['bill_first_name']],
'bill_last_name' => [$_POST['bill_last_name']],
'bill_company_name' => [$_POST['bill_company_name']],
'bill_address_one' => [$_POST['bill_address_one']],
'bill_city' => [$_POST['bill_city']],
'bill_state_or_province' => [$_POST['bill_state_or_province']],
'bill_postal_code' => [$_POST['bill_postal_code']],
'bill_phone' => [$_POST['bill_phone']],
'email' => [$_POST['email']],    
    $MyObj[] = array(
	"cart"=>array(
	"items"=>array(
         'url' => ['https:\/\/www.pdsolutions.ca\/images\/newwhiteheader.png'],
	'description' => [$_POST['description'][$key]],
       'unit_cost' => $unit_cost,
	'quantity' => $value,
	 ),
	'subtotal' => $subtotal,
	),
    ),
    array_push($arr, $MyObj),
]));

    $items_count++;
  }
    
}
?>
<!-- Billing Information -->
<input type="hidden" name="bill_first_name" value="<?=$MyObj->bill_first_name?>">
<input type="hidden" name="bill_last_name" value="<?=$bill_last_name?>">
<input type="hidden" name="bill_company_name" value="<?=$bill_company_name?>">
<input type="hidden" name="bill_address_one" value="<?=$bill_address_one?>">
<input type="hidden" name="bill_city" value="<?=$bill_city?>">
<input type="hidden" name="bill_state_or_province" value="<?=$bill_state_or_province?>">
<input type="hidden" name="bill_postal_code" value="<?=$bill_postal_code?>">
<input type="hidden" name="bill_country" value="<?=$bill_country?>">
<input type="hidden" name="bill_phone" value="<?=$bill_phone?>">
<input type="hidden" name="bill_fax" value="<?=$bill_fax?>">

<?php 
$myJSON =  json_encode($myObj);

echo $myJSON;
}
?>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to Secure Page">
</center>
</FORM>

<?php 
    include("includes/footer.php");
?>
</div>
</body>
</html>

I am getting an output of

YOUR PURCHASE TOTAL IS:

$


null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 
1
 
 Fatigue Management
  
  FM-1301
   
   60
    
    60
     [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["root@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Fatigue Management"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":1}] 
     1
      
      Pesticide Applicator Records
       
       PAR-1302
	
	60
	 
	 60
	  [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["root@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}] [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["root@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}] [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["root@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}]


	  Just wonder how to supress repeats.
-- 
Member - Liberal International This is doctor@nk.ca Ici doctor@nk.ca
Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising!
Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b 
Happy Christmas 2022 and Merry New Year 2023  Beware https://mindspring.com

[toc] | [next] | [standalone]


#19225

From"J.O. Aho" <user@example.net>
Date2022-12-28 09:56 +0100
Message-ID<k12emkF4sbjU3@mid.individual.net>
In reply to#19223
On 28/12/2022 01.34, The Doctor wrote:
> Trying to implement a JSON array in PHP
> Using

<too much code so removed, use a code repository and link to it>

> 	  Just wonder how to supress repeats.

Don't insert the same data multiple times into an array.

Here is a short code demonstrating what you are doing
--- example.php ---
<?PHP
for($i = 0; $i < 3; $i++) { // this replaces the foreach in the original 
code
$MyObj[] = array("same each time", "this from round $i");
var_dump($MyObj);
}
?>
--- eof ---

You can see how the array grows each iteration of the loop.

Some tips:
Separate display and logic into two files, one with only the logic and 
one with only showing the resulting data, this makes it far cleaner and 
simpler to update the design of the page without affecting the logic.

Do not have variable with the same name but different case, it makes 
your code far more difficult to follow and more mistakes can sneak in

Validate input data, always go with whitelisting of what is allowed to 
be in a input, this way you always know the data is safe to use. Regular 
expression can make this simpler.

Always calculate the total, do not trust that from a post or else 
customers gets all the items for free. Also item prices should always be 
fetched from the stored price list, not from a post value.

Store data that you don't want to be manipulated but you need no the 
next page in the session, as this data can't be manipulated by the user 
and you don't need to revalidate the data on each page.

-- 
  //Aho

[toc] | [prev] | [next] | [standalone]


#19228

Fromdoctor@doctor.nl2k.ab.ca (The Doctor)
Date2022-12-28 14:42 +0000
Message-ID<tohkk5$f64$1@gallifrey.nk.ca>
In reply to#19225
In article <k12emkF4sbjU3@mid.individual.net>,
J.O. Aho <user@example.net> wrote:
>On 28/12/2022 01.34, The Doctor wrote:
>> Trying to implement a JSON array in PHP
>> Using
>
><too much code so removed, use a code repository and link to it>
>
>> 	  Just wonder how to supress repeats.
>
>Don't insert the same data multiple times into an array.
>
>Here is a short code demonstrating what you are doing
>--- example.php ---
><?PHP
>for($i = 0; $i < 3; $i++) { // this replaces the foreach in the original 
>code
>$MyObj[] = array("same each time", "this from round $i");
>var_dump($MyObj);
>}
>?>
>--- eof ---
>
>You can see how the array grows each iteration of the loop.
>

Just that we are converting from php to php/json.

Further, the foreach is due to a line that is coming is from
a previous session being passed on.

>Some tips:
>Separate display and logic into two files, one with only the logic and 
>one with only showing the resulting data, this makes it far cleaner and 
>simpler to update the design of the page without affecting the logic.
>
>Do not have variable with the same name but different case, it makes 
>your code far more difficult to follow and more mistakes can sneak in
>
>Validate input data, always go with whitelisting of what is allowed to 
>be in a input, this way you always know the data is safe to use. Regular 
>expression can make this simpler.
>
>Always calculate the total, do not trust that from a post or else 
>customers gets all the items for free. Also item prices should always be 
>fetched from the stored price list, not from a post value.
>
>Store data that you don't want to be manipulated but you need no the 
>next page in the session, as this data can't be manipulated by the user 
>and you don't need to revalidate the data on each page.
>
>-- 
>  //Aho


-- 
Member - Liberal International This is doctor@nk.ca Ici doctor@nk.ca
Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising!
Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b 
Happy Christmas 2022 and Merry New Year 2023  Beware https://mindspring.com

[toc] | [prev] | [next] | [standalone]


#19230

From"J.O. Aho" <user@example.net>
Date2022-12-28 22:09 +0100
Message-ID<k13pjjF4sbjU4@mid.individual.net>
In reply to#19228
On 28/12/2022 15.42, The Doctor wrote:
> In article <k12emkF4sbjU3@mid.individual.net>,
> J.O. Aho <user@example.net> wrote:
>> On 28/12/2022 01.34, The Doctor wrote:
>>> Trying to implement a JSON array in PHP
>>> Using
>>
>> <too much code so removed, use a code repository and link to it>
>>
>>> 	  Just wonder how to supress repeats.
>>
>> Don't insert the same data multiple times into an array.
>>
>> Here is a short code demonstrating what you are doing
>> --- example.php ---
>> <?PHP
>> for($i = 0; $i < 3; $i++) { // this replaces the foreach in the original
>> code
>> $MyObj[] = array("same each time", "this from round $i");
>> var_dump($MyObj);
>> }
>> ?>
>> --- eof ---
>>
>> You can see how the array grows each iteration of the loop.
>>
> 
> Just that we are converting from php to php/json.

The issue ain't related to the conversion, it's you logic that is flawed.

> Further, the foreach is due to a line that is coming is from
> a previous session being passed on.

But it's your foreach loop that makes you to have duplicates in your 
example in the same way as in the small example file. Take some time and 
think about what happens in each iteration, when you know what "$MyObj[] 
=" means, then you can make the proper changes in your own code.

I would also think you could simplify the whole thing for example a lot 
of the data is static, just set that data once not each time in a 
foreach loop and also as Arno already pointed out, don't add a single 
value as an array, you just make things more complex than they need to be.

Remember to not use input type="hidden" for information a user already 
have posted to you, those goes into the session, the only thing would be 
an identifier that is unique for this transaction. Prices you should 
never take from post values, only the amount of items, for if you start 
trust the posted values, I will be able to buy everything you have for 0 
bucks.

-- 
  //Aho

[toc] | [prev] | [next] | [standalone]


#19242

FromH H H H H H H H H H H H H H H H H H E <angel00000100000@icloud.com>
Date2023-01-04 09:10 -0800
Message-ID<62afb95a-5d0e-4c7e-9c77-342b0f983a08n@googlegroups.com>
In reply to#19230
Hey, can U help me ------> https://groups.google.com/g/magic/c/CRDqi-wyQJU


?


Please help...



On Wednesday, December 28, 2022 at 11:09:15 PM UTC+2, J.O. Aho wrote:
> On 28/12/2022 15.42, The Doctor wrote: 
> > In article <k12emk...@mid.individual.net>, 
> > J.O. Aho <us...@example.net> wrote: 
> >> On 28/12/2022 01.34, The Doctor wrote: 
> >>> Trying to implement a JSON array in PHP 
> >>> Using 
> >> 
> >> <too much code so removed, use a code repository and link to it> 
> >> 
> >>> Just wonder how to supress repeats. 
> >> 
> >> Don't insert the same data multiple times into an array. 
> >> 
> >> Here is a short code demonstrating what you are doing 
> >> --- example.php --- 
> >> <?PHP 
> >> for($i = 0; $i < 3; $i++) { // this replaces the foreach in the original 
> >> code 
> >> $MyObj[] = array("same each time", "this from round $i"); 
> >> var_dump($MyObj); 
> >> } 
> >> ?> 
> >> --- eof --- 
> >> 
> >> You can see how the array grows each iteration of the loop. 
> >> 
> > 
> > Just that we are converting from php to php/json.
> The issue ain't related to the conversion, it's you logic that is flawed.
> > Further, the foreach is due to a line that is coming is from 
> > a previous session being passed on.
> But it's your foreach loop that makes you to have duplicates in your 
> example in the same way as in the small example file. Take some time and 
> think about what happens in each iteration, when you know what "$MyObj[] 
> =" means, then you can make the proper changes in your own code. 
> 
> I would also think you could simplify the whole thing for example a lot 
> of the data is static, just set that data once not each time in a 
> foreach loop and also as Arno already pointed out, don't add a single 
> value as an array, you just make things more complex than they need to be. 
> 
> Remember to not use input type="hidden" for information a user already 
> have posted to you, those goes into the session, the only thing would be 
> an identifier that is unique for this transaction. Prices you should 
> never take from post values, only the amount of items, for if you start 
> trust the posted values, I will be able to buy everything you have for 0 
> bucks. 
> 
> -- 
> //Aho

[toc] | [prev] | [next] | [standalone]


#19243 — Stop spamming (Was: JSON and PHP)

From"J.O. Aho" <user@example.net>
Date2023-01-04 19:24 +0100
SubjectStop spamming (Was: JSON and PHP)
Message-ID<k1lujhFb0mU1@mid.individual.net>
In reply to#19242
On 04/01/2023 18.10, H H H H H H H H H H H H H H H H H H E wrote:
> Hey, can U help me ------> https://groups.fakeusergroupagent..example.com/g/magic/c/CRDqi-wyQJU

Only if you stop spamming for 18 months first.

[toc] | [prev] | [next] | [standalone]


#19229

FromArno Welzel <usenet@arnowelzel.de>
Date2022-12-28 19:00 +0100
Message-ID<k13ehqFliofU1@mid.individual.net>
In reply to#19223
The Doctor, 2022-12-28 01:34:

> Trying to implement a JSON array in PHP
> 
> 
> Using
[...]

Can you please reduce such questions this to the relevant part?


[...]
> $myObj = [];
> if (isset($_POST["submit"])){
> (array_push($myObj,[
[...]

Why do you use array_push()? You can just build an array by assigning
values to it:

$myObj['key'] = $value;

[...]
> 'bill_first_name' =>[$_POST['bill_first_name']],

Why do you put an array here?

[$_POST['bill_first_name']] will resolve to a single element array:

'bill_first_name' => [ 'value' ];

Is this really what you want?

[...]
> 	  Just wonder how to supress repeats.

By using correct arrays and not that confusing mixture of values, empty
arrays and single element arrays.


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#19233

FromThE sUn <angel00000100000@mail.ee>
Date2022-12-28 21:28 -0800
Message-ID<b5e2dfb0-2c3e-4fa5-90ec-15f546ce8671n@googlegroups.com>
In reply to#19223
Have a nice day, Doctor......


🌞



On Wednesday, December 28, 2022 at 2:35:00 AM UTC+2, The Doctor wrote:
> Trying to implement a JSON array in PHP 
> 
> 
> Using 
> 
> 
> <?=session_start(); 
> error_reporting(E_ALL); 
> ?> 
> <!DOCTYPE html> 
> <html lang="en"> 
> <head> 
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
> <meta name="robots" content="index, follow" /> 
> <link rel="stylesheet" type="text/css" href="css/css.css"/> 
> <link rel="stylesheet" type="text/css" href="css/css2.css"/> 
> <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen"> 
> <link rel="stylesheet" href="css/uniform.agent.css" type="text/css" media="screen"> 
> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> 
> </head> 
> <body> 
> <?php 
> if(!empty($_SESSION['sessiondata'])){ 
> } 
> ?> 
> <div id="wrapper"> 
> <!--header begins--> 
> <?php 
> include("includes/header.php"); 
> ?> 
> <!--header ends--> 
> <FORM ACTION="https://gatewayt.moneris.com/chkt/request/request.php" method=post> 
> <div id="outerDiv" style="width:400px"; height"300px">` 
> <div id="monerisCheckout"></div></div> 
> <script src="https://gatewayt.moneris.com/chkt/js/chkt_v1.00.js"></script> 
> <script> 
> var myCheckout = new monerisCheckout(); 
> myCheckout.setMode("qa"); 
> myCheckout.setCheckoutDiv("monerisCheckout"); 
> myCheckout.setCheckout([ticket #]); 
> myCheckout.setCallback("page_loaded", myPageLoad); 
> myCheckout.setCallback("cancel_transaction", myCancelTransaction); 
> myCheckout.setCallback("error_event", myErrorEvent); 
> myCheckout.setCallback("payment_receipt", myPaymentReceipt); 
> myCheckout.setCallback("payment_complete", myPaymentComplete); 
> </script> 
> <?php 
> 
> ?> 
> <center> 
> <!-- Store Settings--> 
> <INPUT TYPE="HIDDEN" NAME="ps_store_id" VALUE="<?=$myObj->store_id?>"> 
> <INPUT TYPE="HIDDEN" NAME="checkout_id" VALUE="<?=$myObj->checkout_id?>"> 
> <!------- DEFINE CHARGE TOTAL HERE ---> 
> <br/><br/><h3>Your Purchase Total Is: </h3> <br/> <h2>$<?=$myObj->txn_total?></h2> 
> <INPUT TYPE="hidden" NAME="charge_total" VALUE="<?=$myObj->txn_total?>"><br><br> 
> <!-- Unique Order ID --> 
> <!--INPUT TYPE="hidden" NAME="order_id" VALUE="<?=$myObj->sessValue?>"--> 
> <!-- Additional Optional Details --> 
> <input type="hidden" name="cust_id" value="<?=$MyObj->sessValue?>"> 
> <input type="hidden" name="email" value="<?=$myObj->email?>"> 
> <input type="hidden" name="note" value=""> 
> <!-- Item Information --> 
> <?php 
> 
> $items_count = 1; 
> $subtotal = 0; 
> $arr = array(); 
> foreach ($_POST['quantity'] as $key => $value) { 
> 
> if( $value > 0){ 
> 
> if(isset($_POST['with_gst'][$key])){ 
> $unit_cost = 63.00; 
> }else{ 
> $unit_cost = 60.00; //no gst included 
> } 
> 
> $subtotal = ($unit_cost * $value); 
> $quantity = ($value); 
> 
> 
> ?> 
> <input name="quantity<?=$items_count?>" value="<?=$quantity?>"> 
> <input name="description<?=$items_count?>" value="<?=$_POST['description'][$key]?>"> 
> <input name="id<?=$items_count?>" value="<?=$_POST['id'][$key]?>"> 
> <input name="price<?=$items_count?>" value="<?=$unit_cost?>"> 
> <input name="subtotal<?=$items_count?>" value="<?=$subtotal?>"> 
> <?php 
> $myObj = []; 
> if (isset($_POST["submit"])){ 
> (array_push($myObj,[ 
> 'sessValue' =>[ $_POST['sessionid1']], 
> 'username'=> ["demouser"], 
> 'password' => ["password"], 
> 'store_id' => ["store3"], 
> 'checkout_id' => ["chkt23NGFtore3"], 
> 'api_token' => ["yesguy"], 
> 'txn_total' => [$_POST['charge_total']], 
> 
> 'bill_first_name' =>[$_POST['bill_first_name']], 
> 'bill_last_name' => [$_POST['bill_last_name']], 
> 'bill_company_name' => [$_POST['bill_company_name']], 
> 'bill_address_one' => [$_POST['bill_address_one']], 
> 'bill_city' => [$_POST['bill_city']], 
> 'bill_state_or_province' => [$_POST['bill_state_or_province']], 
> 'bill_postal_code' => [$_POST['bill_postal_code']], 
> 'bill_phone' => [$_POST['bill_phone']], 
> 'email' => [$_POST['email']], 
> $MyObj[] = array( 
> "cart"=>array( 
> "items"=>array( 
> 'url' => ['https:\/\/www.pdsolutions.ca\/images\/newwhiteheader.png'], 
> 'description' => [$_POST['description'][$key]], 
> 'unit_cost' => $unit_cost, 
> 'quantity' => $value, 
> ), 
> 'subtotal' => $subtotal, 
> ), 
> ), 
> array_push($arr, $MyObj), 
> ])); 
> 
> $items_count++; 
> } 
> 
> } 
> ?> 
> <!-- Billing Information --> 
> <input type="hidden" name="bill_first_name" value="<?=$MyObj->bill_first_name?>"> 
> <input type="hidden" name="bill_last_name" value="<?=$bill_last_name?>"> 
> <input type="hidden" name="bill_company_name" value="<?=$bill_company_name?>"> 
> <input type="hidden" name="bill_address_one" value="<?=$bill_address_one?>"> 
> <input type="hidden" name="bill_city" value="<?=$bill_city?>"> 
> <input type="hidden" name="bill_state_or_province" value="<?=$bill_state_or_province?>"> 
> <input type="hidden" name="bill_postal_code" value="<?=$bill_postal_code?>"> 
> <input type="hidden" name="bill_country" value="<?=$bill_country?>"> 
> <input type="hidden" name="bill_phone" value="<?=$bill_phone?>"> 
> <input type="hidden" name="bill_fax" value="<?=$bill_fax?>"> 
> 
> <?php 
> $myJSON = json_encode($myObj); 
> 
> echo $myJSON; 
> } 
> ?> 
> <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to Secure Page"> 
> </center> 
> </FORM> 
> 
> <?php 
> include("includes/footer.php"); 
> ?> 
> </div> 
> </body> 
> </html> 
> 
> I am getting an output of 
> 
> YOUR PURCHASE TOTAL IS: 
> 
> $ 
> 
> 
> null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 
> 1 
> 
> Fatigue Management 
> 
> FM-1301 
> 
> 60 
> 
> 60 
> [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["ro...@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Fatigue Management"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":1}] 
> 1 
> 
> Pesticide Applicator Records 
> 
> PAR-1302 
> 
> 60 
> 
> 60 
> [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["ro...@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}] [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["ro...@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}] [{"sessValue":[null],"username":["demouser"],"password":["password"],"store_id":["store3"],"checkout_id":["chkt23NGFtore3"],"api_token":["yesguy"],"txn_total":["126.00"],"bill_first_name":["Dave"],"bill_last_name":["Yadallee"],"bill_company_name":[""],"bill_address_one":[""],"bill_city":[""],"bill_state_or_province":[""],"bill_postal_code":[""],"bill_phone":["7804734587"],"email":["ro...@nk.ca"],"0":{"cart":{"items":{"url":["https:\\\/\\\/www.pdsolutions.ca\\\/images\\\/newwhiteheader.png"],"description":["Pesticide Applicator Records"],"unit_cost":60,"quantity":"1"},"subtotal":60}},"1":2}] 
> 
> 
> Just wonder how to supress repeats. 
> -- 
> Member - Liberal International This is doc...@nk.ca Ici doc...@nk.ca 
> Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising! 
> Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b 
> Happy Christmas 2022 and Merry New Year 2023 Beware https://mindspring.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web