Results from the most recent live auction are here .
22 members in the live chat room. Join Chat !
01-09-2007, 05:27 PM
· #1 NamePros Regular
Name: Alex
Location: Uk
Join Date: Nov 2006
Posts: 601
NP$: 133.80 (
Donate )
[php] passing variables to different sites
hi, i want to send a variable to a site i link to.
i cannot use a form, the script has to send the var without any user input.
ie, when i click an affilate link on my site, it redirects to a page on the site, which sends the var onto the next site.
using get is a last resort, because ideally i dont want the user to see the var.
01-09-2007, 08:06 PM
· #2 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
I think you are going to have to pass the variable with get unless you want to make some JS script that creates a form, the action, the inputs, and submits it..
01-09-2007, 08:33 PM
· #3 NamePros Regular
Join Date: Apr 2006
Posts: 278
NP$: 2050.00 (
Donate )
__________________ Chimps.ca - Swans.ca - Snails.ca
01-09-2007, 08:41 PM
· #4 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
01-10-2007, 12:41 AM
· #5 New Member
here's code for two ways...
without using GET, you can do with a simple form and JS event to submit...
Code:
<form id="mysecretform" method="POST" action="http://link.to/passvar.to">
<input type="hidden" name="mysecretvar" value="itsasecret" />
</form>
<a href="#" onclick="document.getElementById('mysecretform').submit();">Method 1</a>
And like Dan said, you can make it all in a JS function to do it all so it's all reusable and such...
within <head> section...
Code:
<script type="text/javascript">
function sendSecret(myVar, myVal, target) {
hiddenVal = document.createElement("input");
hiddenVal.type = "hidden";
hiddenVal.name = myVar;
hiddenVal.value = myVal;
myForm = document.createElement("form");
myForm.method = "POST";
myForm.action = target;
myForm.appendChild(hiddenVal);
document.body.appendChild(myForm);
myForm.submit();
}
</script>
and on the link...
Code:
<a href="#" onclick="sendSecret('mysecretvar', 'itsasecret', 'http://link.to/passvar.to');">Method 2</a>
I tested them on FireFox, it should work on all browsers though
Last edited by plong0 : 01-10-2007 at 12:46 AM .
01-10-2007, 12:43 AM
· #6 NamePros Regular
Name: Sam Cleaver
Location: England
Join Date: May 2005
Posts: 346
NP$: 59.50 (
Donate )
From what your saying... do you mean just using GET?
Quote: ie, when i click an affilate link on my site, it redirects to a page on the site, which sends the var onto the next site.
You could just use get and obfuscate the variables by encoding the values. Just set link to something like mypage.php?var1=lol&var2=whatever&etc=etc
__________________
-Beaver6813.com V5 Soon!
01-10-2007, 04:36 AM
· #7 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
Originally Posted by manofgames using get is a last resort, because ideally i dont want the user to see the var.
Try plong0's code.
01-10-2007, 05:42 AM
· #8 NamePros Regular
Name: Alex
Location: Uk
Join Date: Nov 2006
Posts: 601
NP$: 133.80 (
Donate )
thanks for your help.
i think the simplest way for me to do it is encode the var and sand it via get.
problem resolved
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off