Solved

Passing Variables in URL

Posted on 2011-09-19
4
290 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:Nathan Riley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

623 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