Link to home
Start Free TrialLog in
Avatar of anelson2008
anelson2008

asked on

How to insert PHP variable into URL?

Hi,

We are trying to make a simple payment form that takes a price from a hidden field and inserts that number into a URL for WorldPay to process that payment. So far we have the form and the correct URL for a fixed price payment but ideally we'd like the URL to be constructed with this variable price, so far we have this:

Any advice gratefully received! Thanks, Adrian.

<input type=hidden name="recipients" value="myemailaddress">
<input type=hidden name="subject" value="payment form">
<input type=hidden name="good_url" value="https://select-test.worldpay.com/wcc/purchase?instId=000000&cartId=WorldPay+Test&amount=40&currency=GBP&desc=WorldPay+Test&testMode=100">

Open in new window

Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

how is the value for good_url written to that HTML element? There has to be some dynamic script that writes that URL.
Avatar of tben2008
tben2008

So you want it to take subject , recipients and good_url. Then redirect to a page using that information.
Avatar of anelson2008

ASKER


MMD - good_ul is for FormMail.php which is using the information to post us a mail, good_url is the redirect which it goes to after posting the results of the form to us

tben2008 - we basically need a hidden field with a variable number in (that we can change manually) that'll form the price so in English (!) something like:

hiddenbox with price in (VAR)

We need to change good_url to:

https://select-test.worldpay.com/wcc/purchase?instId=000000&cartId=WorldPay+Test&amount=**VAR**¤cy=GBP&desc=WorldPay+Test&testMode=100"

but don't know how - plus can't alliterate it very well either!! Sorry.

Adrian


<?php // RAY_hidden_to_URL.php
 
if (!empty($_POST)) {
	echo $_POST["good_url"] . '&recipients=' . $_POST["recipients"] . '&subject=' . $_POST["subject"];
	die();
}
?>
 
<html>
<form method="post">
<input type=hidden name="recipients" value="myemailaddress">
<input type=hidden name="subject" value="payment form">
<input type=hidden name="good_url" value="https://select-test.worldpay.com/wcc/purchase?instId=000000&cartId=WorldPay+Test&amount=40&currency=GBP&desc=WorldPay+Test&testMode=100">
<input type="submit" value="Click Here" />
</form>
</html>

Open in new window

Let me get this right. You want it to send the information to you and redirect to the good_url. Or for them all to be send to you.
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Don't forget to urlencode if you are sending it over the www!

Cheers, ~Ray
Kind of surprised you are asking to close this without giving any points for help.  

Especially since your OP said "trying to make a simple payment form that takes a price from a hidden field" and our posts here showed you EXACTLY how to do that, but the solution you posted doesn't even have a <form> statement in it.  

Are you sure you understand how EE works??  Why should we help you with your next question?
Ray, thanks for your post. Obviously we don't know each other but I'm sure if we did you'd probably think I was a decent chap and no doubt I'd may think likewise. If I've misunderstood the concept of how this all works (it involves the internets, a series of tubes right?) I'm happy to put right whatever I've done wrong. As for what I ended up doing, well, it worked for me - kinda dumb question with an equally dumb solution, granted, but we're all allowed off-days! Let me know what I should do & sorry to anyone else I may have offended.
Have a look at these links - the HELP page is rather long and most of the EE community has never read it in its entirety, but it gives some good cultural background information.  The Experts here volunteer their service and knowledge in exchange for points (and occasionally T-shirts that we can wear to job interviews).

https://www.experts-exchange.com/help.jsp#hi403
https://www.experts-exchange.com/help.jsp#hi407

See what you think.  Best, ~Ray
Sometimes I just don't get it.

 Why should we help you with your next question?

~Ray
Hi, Lunchy.  Apologies to you and anelson2008 if I was sounding too critical.  

The whole close/award points process may look different to you than it does to us.  On this end, what we see is the author saying thanks for all your help and goodbye.  I asked why there were no points for help.  Then, later on, we see the same goodbye thing again.  For some reason, the OP comments on closing the question do not show up in the comment stream above.  Perhaps if it did, the dialog would be easier to understand on both sides.

I think this may have come in one of those weeks when there were a lot of folks closing out their posts after lengthy dialogs with "Nevermind, I found the answer."  It can be frustrating when you've spent a good bit of time trying to help someone.

Anyway, no hard feelings on my part, and sorry if I rankled anyone.  Back to work.  Best regards, ~Ray
Thanks for your messages, please can you help me close the question in the right way - according to the help page I need an "accept multiple solutions" button which I can't see!
Hey, anelson2008 - Best regards, for 2009, ~Ray