PDA

View Full Version : problem with putting cookie data into paypal var


atapi
11th December 2004, 10:02 AM
Hi all
I am using mambo cms and I want to add a paypal form
but I cant use the webradev script because mambo doesnt seem to allow php code to execute inside the cms. So I can seem to get the custom field to putt the cookie data in and pass it to paypal.

Does anyone know a way to write a form for mambo that does require the use of php that will still get the cookie data into the custom paypal var?

Thanks
atapi

mark
14th December 2004, 10:21 AM
so in fact, the only problem is that you are not able to run php code inside the cms?

How abut using javascript version? It does the same..
You have to put this function to some template so that it will appear between the <head>...</head> tags:

<SCRIPT>
function getCookie(name)
{
var nameequals = name + "=";
var beginpos = 0;
var beginpos2 = 0;
while (beginpos < document.cookie.length)
{
beginpos2 = beginpos + name.length + 1;
if (document.cookie.substring(beginpos, beginpos2) == nameequals)
{
var endpos = document.cookie.indexOf (";", beginpos2);
if (endpos == -1)
endpos = document.cookie.length;
return unescape(document.cookie.substring(beginpos2, endpos));
}
beginpos = document.cookie.indexOf(" ", beginpos) + 1;
if (beginpos == 0)
break;
}

return null;
}
</SCRIPT>


and then instead of using

<input type="hidden" name="custom" value="<?=$_COOKIE['POSTAff2Cookie']?>">

you will use

<script>
document.write("<input type='hidden' name='custom' value='"+getCookie('POSTAff2Cookie')+"'>");
</script>


let me know if it worked.

regards,

mark