Solved

Passing Variables in URL

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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

752 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