Solved

Passing Variables in URL

Posted on 2011-09-19
4
280 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Read about why website design really matters in today's demanding market.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

11 Experts available now in Live!

Get 1:1 Help Now