I want to pass the varying value of "subid" in this url: http://abcwebsite.php?subid=xxxxxx into "source" in this url: http://xyzwebsite.htm?source=xxxxxx The page will open with: <?php header ("location:http://xyzwebsite.htm?login=apin&source=xxxxxx"); ?> Code (markup): Howwever, the value of xxxxxxx is not fixed so I need to specify it in general terms but huntiing for clues has not turned up how to do it. Any suggestions?
Where do you set the value xxxxxx? It must be a variable with if statements I presume. Show that code.
The value for xxxxxxx is generated by someone else, an affiliate marketing company. It just appears in the url (to be used for identification purposes).
My question is for a place to start. For example, if someone wanted to have email addresses copied to a text file, a good suggestion would be to look at fwrite at: http://ca.php.net/manual/en/function.fwrite.php Starting with that, one could address the problem with an appropriate code attempt for that purpose. That is what I am asking for, a suggestion as to where to begin or where to look so I can get started. Then if the code I write does not work, I will post it then.
It seems that this should work, but does not: <?php header ("location:http://xyzwebsite.htm?login=apin&source=".$_GET['subid']); ?> Code (markup): The page opens, but source= has no value. However, when I include the following in the form: <input type="hidden" name="subid" value="<?php echo htmlentities($_GET['subid']); ?>" /> Code (markup): the value of subid is included in the email. So I can get $_GET['subid'] to work for the email, but not for url to url. Is there some other function I should use?
If the subid has spaces or odd characters in it, you'll need to use urlencode($_GET['subid']) as the argument to header().
subid= has no spaces or odd characters. Let me expand upon the problem: I am trying to get $_GET['subid'] to transfer a variable six digit integer from one url to another. The process is like this: A link on a site (not mine) is clicked opening my page whose url looks like this: http://abcwebsite.php?subid=xxxxxx where xxxxxx represents a variable integer of 6 varying digits with no spaces or odd characters, but I don't control what the digits are. Then a link on my page is clicked and another website page (not mine) opens looking like this: http://xyzwebsite.htm?source= I want source= to take on the value of subid=. When I try this: <?php header ("location:http://xyzwebsite.htm?login=apin&source=".$_GET['subid']); ?> Code (markup): the url shows no value for source=. When I try this: <?php header ("location:http://xyzwebsite.htm?login=apin&source=".(int)$_GET['subid']); ?> Code (markup): the url shows source=0. When I try this: <?php header ("location:http://xyzwebsite.htm?login=apin&source=".(htmlentities)$_GET['subid']); ?> Code (markup): the page will not open. When I try this: print '<meta http-equiv="refresh" content="0;URL=http://xyzwebsite.htm?login=apin&source=?'.(int)$_GET['subid'].'">'; Code (markup): the url shows source=%3F0 On the same page, the following works to capture the value of subid for inclusion in an email: <input type="hidden" name="subid" value="<?php echo ($_GET['subid']); ?>" /> Code (markup): If it works in a hidden field for emailing, why won't ($_GET['subid']) work for url to url?
I certainly commend you for your thoroughness; you've got a good programmer's mind I know many so-called "experienced" PHP programmers who are far less didactic with their debugging. A few of the commands you tried didn't work because they were syntactically invalid, so they would either (a) halt the php process, hence no page render, or (b) result in nothing/garbage being printed. It seems that all of your calls are missing a domain. e.g., you have http://xyzwebsite.htm and http://wyxwebsite.php everywhere instead of http://[b]domain.com[/b]/wyxwebsite.php I just built a mini-system to do what you want and it works fine, so...I'm not sure what I'm missing with your setup. here's what I just did: A file named in.php contains this: <?php header ("Location: http://localhost/process.php?login=apin&source=".strval(rawurlencode($_GET['subid']))); ?> PHP: The rawurlencode() is important, because it transforms invalid input (in case the caller tries to mess up your page) into "safe" characters. The strval() is important because sometimes (depending on the setup) PHP will strip leading zeroes from integers, so a param of '000456' would look like '456' on your forward. In my process.php file, which the above code redirects to, I have this: <? echo "you sent an id of: " . htmlentities($_GET['source']) . '.'; ?> PHP: The htmlentities() is important because it converts invalid input to browser-friendly codes so that your display doesn't mess up. Again, a valid integer code won't contain these, but a malicious user might pass in bogus data. The code I posted above works perfectly. The redirect takes place, the parameter is renamed, the target page can parse it and display it. Perhaps you can test this code on your system and see if it works. If it doesn't, it'll be easier to debug two one-line programs than your entire set of scripts.
Thank you for your interest, sea otter. When I get this resolved, I will incorporate your suggestions regarding strval() etc. I should restate what the process is to avoid any misunderstanding: The six digit value of subid= is from someone else who assigns the value according to whoever is the origin. i.e., each originator has a unique six digit number. When a link is clicked on someone else's site, the assigned value of subid is included in the query string in the url of my page as represented by: http://abcwebsite.php?subid=xxxxxx A link on my page goes to a separate php file which contains only the code in question and nothing else. When the link is clicked, the result is that it goes to someone else's page, so I don't see how <? echo "you sent an id of: " . htmlentities($_GET['source']) . '.'; ?> Code (markup): can be employed. source= does not appear on any of my pages, only on http://xyzwebsite.htm?source= which is not my site. I am sending a value received from someone else along to someone else. I am getting the value in my url, but am unable to pass it along to the url of the one following me. Maybe the separate php file cannot access the value of subid= unless it is specified in the link to it on page http://abcwebsite.php?subid=xxxxxx. I tried <a href="http://abcwebsite/separate.php?.$_GET['subid']);"> but that did not change anything.
I now realize the problem, and can now pose a better question. Where do I look to find out how to send a particular query string value, subid=, from http://abcwebsite.php?subid=xxxxxx to http://abcwebsite/separate.php when the link, <a href="http://abcwebsite/separate.php">info</a> is clicked? This code which is in the separate.php file: <?php header ("location:http://xyzwebsite.htm?login=apin&source=".$_GET['subid']); ?> may then be enabled to send the value into the query string of: http://xyzwebsite.htm?source= If I make the link like this: <a href="http://abcwebsite/separate.php?"subid=<?php echo ($_GET['subid']); ?>>info</a> the value shows in the link (view source), but it has to be sent to http://abcwebsite/separate.php before it can end up in the query string of http://xyzwebsite.htm?source=
So now I put " in the right place instead of where I had it: <a href="http://abcwebsite/separate.php?subid=<?php echo ($_GET['subid']); ?>">info</a> Code (markup): Now it all works. Solved.