Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing Variables in URL

Posted on 2011-09-19
4
Medium Priority
?
291 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 668 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 664 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 668 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

721 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