Solved

Passing Variables in URL

Posted on 2011-09-19
4
282 Views
Last Modified: 2012-05-12
I know nothing of PHP coding, but recently have been given a project to create a checkout system via Quickbooks.  I have looked through the API and I see how it works and understand it, but I don't know how to code this into a PHP file.

I start with a url

that takes me to a page that gives me 2 different numbers I have to encode them and them as javascript then put it into another url.  At that point the payment gateway takes the rest.  Is there any tutorial or direction you could send me would be great.

Thanks.
0
Comment
Question by:N R
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 167 total points
ID: 36564417
Passing variables in a URL isn't secure but that's not your call.  As for my answer, feel free to ask questions.  I'm not sure of your background except you haven't worked in PHP but know what an API is.

At this point, I'm not even sure you need PHP because from your description Javascript is doing all the work.  It could be I don't understand what you want.  Anyway...

Let's say we want to pass a credit card transaction via URL.  This is a bad idea but I'm just trying to give you an example.

https://www.bigbank.com/receivepayment?account=4444444444444444&exp=0412&amount=100_00

You can just build a URL like that using Javascript.

You might still need PHP if I don't understand the question.  A good primer for PHP is at
http://www.w3schools.com/php/
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36564423
I used an underline character between the 100 and the 00 but it doesn't show up since the URL itself got underlined.  Oh well.  (I'd send the transaction as pennies anyway, 10000, were I to send it.  I just wouldn't use the URL to send it.)
0
 
LVL 7

Assisted Solution

by:boon86
boon86 earned 166 total points
ID: 36565865
hi,

You can use session to pass the variable:

page1.php:

<?php
session_start();

$_SESSION['var1'] = "Product A";
$_SESSION['var2'] = "Price: $50";

?>

Open in new window


call the variable you stored on page1 to page 2
page2.php:

<?php
session_start();

echo "My Product is: ".$_SESSION['var1'];
echo "Product Price is: ".$_SESSION['var2'];

?>

Open in new window


hope that help
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 167 total points
ID: 36592985
I know nothing of PHP coding - we all have to start somewhere.  Here is a good place to begin.
http://www.sitepoint.com/books/phpmysql4/

The URL variables show up inside your PHP script in an array variable named $_GET.  This will print them out for you:

<?php var_dump($_GET);

It violates the laws of the HTTP(s) protocol to make any change to the underlying data model based on the contents of a GET method request.  GET requests are the ones that have URL variables.  If you want to change anything in your data model, you should use a POST request instead.  POST requests populate a PHP array named $_POST.

But to the most important part of this question... If I were you, I would think very carefully before accepting this project.  There are criminal penalties for making mistakes with online financial data, and some of them involve handcuffs and prison time.  I would not want to start my PHP career with something that has unacceptable legal risks if I make a mistake.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get domain with php 7 20
javascript date picker in php while loop 5 28
How to count in a table in php 22 19
mysql update statement 3 0
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now