Encrypted URLs

22 posts by 2 authors in: Forums > CMS Builder
Last Post: August 20, 2012   (RSS)

By Jason - August 13, 2012 - edited: August 16, 2012

Hi Jerry,

Using this type of implementation, you won't be able to have any javascript functions on the page, as the redirection will occur before anything on the page is ever submitted to the browser.

After that, it looks like the issue is that you're trying to create a string that has HTML form elements inside of it. The redirect function will try to redirect your browser to a url, so the HTML in the string will cause a problem.

If you need form values in the URL string, you need to build up the string with the variable/value pairs in it. For example:

f ($value == 1) {

$url = "https://www.paypal.com/cgi-bin/webscr?";
$url .= "cmd = _xclick&";
$url .= "lc=US&";
$url .= "cbt=".urlencode("founding member renewal")."&";
$url .= "currency_code=USD&";
$url .= "rm=1&";
$url .= "cpp_header_image=".urlencode("http://www.artistsofpalmbeachcounty.org/images/apbcpp.jpg")."&";
$url .= "business=".urlencode($ppea1)."&";
$url .= "item_name=". urlencode($rmda)."&";
$url .= "amount=".urlencode($rmda)."&";
$url .= "no_shipping=1&";
$url .= "no_note=1&";
$url .= "return=".urlencode($ret1);
}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Encrypted URLs

Hi Jason,

Thanks to your explanation I think I’m almost there and I’m sorry if I’m becoming a pest, but the although the code you suggested (without the Javascript) redirects the information to the PayPal URL, it doesn’t seem to include any variable values from the database. (FYI: I also removed the extra spaces in the line: $url .= "cmd=_xclick&"; )

Thanks,

Jerry Kornbluth

The resulting URL sent to PayPal (without any of the variable data) is:
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&lc=US&cbt=regular%20member%20renewal&currency_code=USD&rm=1&cpp_header_image=http%3A%2F%2Fwww.artistsofpalmbeachcounty.org%2Fimages%2Fapbcpp.jpg&business=&item_name=&amount=&no_shipping=1&no_note=1&return=http%3A%2F%2Fwww.jkwebdesigns.com
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Jason - August 14, 2012

Hi Jerry,

How are the variables $common_informaitonRecord and $become_a_memberRecord being retrieved from the database on your page?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Encrypted URLs

By gkornbluth - August 14, 2012 - edited: August 14, 2012

Hi Jason,

Embarrassed as I am, based on your last comment I fixed a few typos and I thought I had it working perfectly.

I could get the code to execute perfectly with a URL value of 1, (all the variable values end up in the right places and the PayPal page rendered correctly).

However, if I clicked the link for a URL value of 2, no variable data was inserted into the resulting URL.

What I found is that I had to change the numbers 1, 2, 3 etc. to the words 'one' 'two', 'three' etc. for it to work.

I don't understand why, could you explain?

Could you also let me know which is correct (preferred)?
$url .= "cbt=".urldecode("regular member renewal")."&";
$url .= "cbt=".urlencode("regular member renewal")."&";
or
$url .= "cbt=regular member renewal&";

As always, thanks for all your help,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Jason - August 15, 2012

Hi,

You'd want to use urlencode instead of urldecode. This is normally used to take care of any special characters that may appear. However, since it's just text, the last option should work as well. Did the second option produce no result?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Encrypted URLs

Hi Jason,

No, they all seemed to produce the same result, but I encountered the 3 versions in different fields of the example code and wanted to check.

Any insights into the text vs numbers?

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Jason - August 16, 2012

Hi Jerry,

Ah, I understand the confusion. In the example, urldecode way a typo caused by my editors autocomplete. It should be urlencode, and I've changed it in the post.

If you process the form using that method, does it produce no result in the string? Could you post what you have along with example output?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Encrypted URLs

Here you go.

URL with a value of 1 (correct data pulled from database)

<a href="intermediate.php?url=1">Click Here for link 1!</a>

URL

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amount=50.00&business=payments%40artistsofpalmbeachcounty.org&lc=US&cbt=regular%20member%20renewal&currency_code=USD&rm=1&cpp_header_image=http%3A%2F%2Fwww.artistsofpalmbeachcounty.org%2Fimages%2Fapbcpp.jpg&item_name=regular%20member%20renewal&no_shipping=1&no_note=1&return=http%3A%2F%2Fwww.jkwebdesigns.com&

URL with a value of 2 (no data from database)
<a href="intermediate.php?url=2">Click Here for link 2!</a>

URL

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amount=&business=&lc=US&cbt=founding%20member%20renewal&currency_code=USD&rm=1&cpp_header_image=http%3A%2F%2Fwww.artistsofpalmbeachcounty.org%2Fimages%2Fapbcpp.jpg&item_name=founding%20member%20renewal&no_shipping=1&no_note=1&return=http%3A%2F%2Fwww.jkwebdesigns.com&

_______________________________
Intermediate Code
<?php
$value = @$_REQUEST['url'];

$url = "";
if ($value == 1) {

$url = "https://www.paypal.com/cgi-bin/webscr?";
$url .= "cmd= _xclick&";
$url .= "amount=".urlencode($rmda)."&";
$url .= "business=".urlencode($ppea1)."&";
$url .= "lc=US&";
$url .= "cbt=regular member renewal&";
$url .= "currency_code=USD&";
$url .= "rm=1&";
$url .= "cpp_header_image=".urlencode("http://www.artistsofpalmbeachcounty.org/images/apbcpp.jpg")."&";
$url .= "item_name=regular member renewal&";
$url .= "no_shipping=1&";
$url .= "no_note=1&";
$url .= "return=".urlencode($ret1)."&";
}

elseif ($value == 2) {

$url = "https://www.paypal.com/cgi-bin/webscr?";
$url .= "cmd= _xclick&";
$url .= "amount=".urlencode($fmda)."&";
$url .= "business=".urlencode($ppea1)."&";
$url .= "lc=US&";
$url .= "cbt=founding member renewal&";
$url .= "currency_code=USD&";
$url .= "rm=1&";
$url .= "cpp_header_image=".urlencode("http://www.artistsofpalmbeachcounty.org/images/apbcpp.jpg")."&";
$url .= "item_name=founding member renewal&";
$url .= "no_shipping=1&";
$url .= "no_note=1&";
$url .= "return=".urlencode($ret1)."&";

}

if ($url) {
redirectBrowserToURL($url);
}
exit;
?>


Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Jason - August 17, 2012

Hi Jerry,

Something must be happening in the way records are being retrieved between url = 1 and url = 2. Could you attach the complete file?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/