Passing Variables (SbD)

Get help with nopcart Perl, PHP or ASP checkout related issues.

Moderators: Koibito, Stefko, Randy

Passing Variables (SbD)

Postby Randy » Fri Jan 20, 2006 2:15 pm

Check out what form variables are being passed to your PHP script by using this file.

1) Save this file as formprocessor.php
2) Point your checkout form to it: action = "formprocessor.php" method='POST'
3) upload to your server.
4) fill in the checkout form and submit

You will see a list of all the variable names and values that are received by the form processor.

Make sure these are the right variables for checkout.php.

Takes out the "wonder if..." :lol:

Code: Select all
<?php
/*  Script name:  formprocessor.php
 *  Description:  Script displays all the information passed
 *                from a form.
 */
  session_start();

  echo "<html>
        <head><title>Posted Variables</title></head>
        <body>";
  foreach ($_POST as $field => $value)
  {
     echo "$field = $value<br>";
  }


?>
</body></html>


Randy
JRS SERVICES
e-commerence solutions
www.jrsservices.net
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Re: Passing Variables (SbD)

Postby Pconno » Sun Dec 09, 2007 10:21 pm

Hi Randy

I am using checkout.php and my variables seem as they are not going through to the script.
But, I just tried you formprocessor.php script above and, SURPRISE, THEY DO GET THROUGH properly: formprocessor.php lists their values ok, all of them!
When I post to checkout.php (I am using the original script with my personal variable defs for $header etc) I get the following error msg:
Notice: Undefined variable: b_first in c:\Web\Boutique\cgi-bin\checkout.php on line 100
The form you submitted was not complete...

If I try to echo my variables, they are all undefined. Say I put this code at the begining of the "MAIN" section:
echo "First name is $b_first <br>";
echo "Email is $b_email <br>";
exit;
Then I get and "undefined variable..." error message and my text prints without values.

Further, I have to add "global $header,$footer;" statement in each of the functions that use them, otherwise they are undefined as well. This of course seems a different prob since those are defined locally within the script.

I suppose there is only a tiny "camel hair" detail missing, but what is it?
Can you help?

Pierre
Pconno
WebMaster
 
Posts: 2
Joined: Sun Dec 09, 2007 9:57 pm

Re: Passing Variables (SbD): one step further

Postby Pconno » Tue Dec 11, 2007 2:01 am

Finally found 2 different ways to recover part of my var values in the checkout.psp script.
1, At the top of the "MAIN" section, I wrote one line per var, such as
$b_first = $_POST['b_first]);
This recovers all vars filled in by the user, and the TOTAL, SUBTOTAL ... vars
No so for the basket item vars. Here's why. The script expect to receive vars like ID_1, ID_2 ... one for each item in the basket. What the script actually recovers is ONE single var named "ID_". I can cheat and write the following line:
$ID_1 = $_POST['ID_'];
That would recover the values for one basket item. But then what about ID_2, ID_3 ... They are said "undefined". Actually, even if there are more than one item in the basket, the script seems to receive only one ID_ variable, the one corresponding to the last item that was put in the basket. So, I am stuck here: I can handle only 1 basket item per session!!!

Okay. I found out that if I would declare "register_globals = on" instead of "off" in the PHP.INI file on my server, my vars would be recovered automatically. This is TRUE. After modifying my PHP.INI file, I do not need the "$b_first = $_POST['b_first'];" lines anymore. But still, my basket item vars are missing, and are not recovered. I am still stuck in the same situation as above. I can still cheat for the first basket item, but then no more than 1 item per session!!! Which of course is not the way to do it.

At last, there propably is a good side to it: I am getting to learn php, ever so slowly!!!
NOTE THAT SAME GOES WITH THE DEMO VERSION
I suppose the problem must be with a config setting somewhere because I have the same problem wether I use checkout.pl or checkout.php: simply stated, the cart items values (product name, id, qty etc) do not make their way to the checkout scripts (confirmation message and csv file)

Anybody can help or advise?

Pierre
Pconno
WebMaster
 
Posts: 2
Joined: Sun Dec 09, 2007 9:57 pm

Re: Passing Variables (SbD)

Postby billw1954 » Mon Jun 18, 2012 8:50 pm

was this problem ever resolved, because it's exactly what's happening with mine.
it appears to be a flaw in the nopcart.js script or i have some setting wrong.
everything comes through the the final emails but the quantity price items get overwritten are served as the last item in the list
billw1954
WebMaster
 
Posts: 1
Joined: Mon Jun 18, 2012 8:43 pm

Re: Passing Variables (SbD)

Postby trader4300facebook » Sun Sep 30, 2012 4:13 am

I am glad I finally stumbled across your posts because I just spent 8 hours coding in all the array variables, as you have.
I didn't know anything about changing any settings on the php.ini file. This should have been stated up front.
I will try changing that file, wherever it is, and see where it goes from there.
trader4300facebook
WebMaster
 
Posts: 37
Joined: Sat Sep 29, 2012 5:08 pm


Return to Help: Perl/PHP/ASP Checkout

Who is online

Users browsing this forum: Google [Bot] and 1 guest