NOTE: I am not well versed in PHP, but have been using the simple code below to append variables to my URLs and links. Add at the top of webpage: <?php $page = $_GET['w']; ?> Then my link is: www.mydomain.com/goto/?subid=<?php echo "$page"; ?> Code (markup): My question is, what do I add to the top of my webpage code if I wanted to append using more than one variable, other than 'w'? Like 'kw' and 'w' and 'sub'.
<?php $page = $_GET['id']; if ($page == "home") { //content. E.g. domain.com/index.php?id=home } elseif ($page == "settings") { //content. E.g. domain.com/index.php?id=settings } elseif ($page == "logout") { //content. E.g. domain.com/index.php?id=logout } else { //Content if no valid id } ?> Code (markup): If that's what you mean?
Nice try....but the script is wrong. Your script is changing what is after the 'id' part, but I need it to recognize different 'ids' and then append it to the link I have above. For example, the script would recognize 'id' and 'sub' and 'kw' and 'subid' that is located in the referer link and whatever comes after that parameter would be appended to the link on my website: www.mydomain.com/goto/?subid=<?php echo "$page"; ?> Yet another example: Refer link to my website: www.yahoo.com/?kw=stuffgoeshere >> then the script would append to my affiliate link of >> www.mydomain.com/goto/?subid=<?php echo "$page"; ?> >> which would look like this once clicked >> www.mydomain.com/goto/?subid=stuffgoeshere. Another referer link to my website: www.yahoo.com/?id=morestuff >> then the script would append to my affiliate link of >> www.mydomain.com/goto/?subid=<?php echo "$page"; ?> >> which would look like this once clicked >> www.mydomain.com/goto/?subid=morestuff.
Your code in your original post doesn't make any sense :/ You are capturing $_GET['w'] from nowhere, then creating a new URL to click on based on that? It's very confusing.. So I'll explain the GET method briefly.. $_GET['w'] would return the value of 'w' in the URL. Example: At this URL - somesite.com/index.php?w=pagename, $_GET['w'] would return the string "pagename". Moving on: somesite.com/index.php?pageid=1&pagename=home§ion=main In that URL there are three GET variables sent. $_GET['pageid'] contains the string "1" $_GET['pagename'] contains the string "home" $_GET['pageid'] contains the string "main"
The code above (both of them) make complete sense. It is you that doesn't understand the concept and meaning of the code. BTW, the snippet I posted works perfectly, but I need it to recognize other parameters like 'id' and 'kw' etc. You need to read the 2nd post I made as well. Between that and the original posting, this is about as clear as anyone could ever lay out for you. It doesn't get any clearer than this if you can comprehend english. Obviously this is for tracking purposes within affiliate marketing. If anyone is not well versed in appending keywords to the end of subids (affiliate links) through this code....then please move on. Chuck.... if you have specific questions that you would like clarification on, that isn't ALREADY stated above, then PM me or SKYPE me: grafx77. More explanation on the code, if needed, can be located here: http://www.warriorforum.com/main-in...version-tracking-i-need-track-everything.html
No it's not clear. It sounds like it was written by an idiot. Are you an idiot or do you lack communication skills? Now before you get defensive and try to respond with something you think is witty and clever don't bother because it's the internet and I could careless about your opinion. Now to your question... First off...I had to consult with a retarded 7 year old to understand the problem you are TRYING to address... If the REFERRING URL to your site is www.yahoo.com/?kw=stuffgoeshere the referring URL is held in the $_SERVER['HTTP_REFERRER'] ENV variable. If you would like to access the "kw" parameter of the REFERRING URL you will have to know how to parse it. Which is simple. PHP has a special function called "parse_str" which will parse the string for you. All you have to do is get the query string. Which is also simple since PHP has another special function called "parse_url". Refer to the following code: $parsed = parse_url($_SERVER['HTTP_REFERRER'], PHP_URL_QUERY); parse_str($parsed, $query); print $query['kw']; PHP: $query['kw'] will give you what you want. If you want to then append it to your CURRENT url just redirect back the script with the new QUERY attached. Understand? Now that I gave you a general idea of how to do it... don't forget to take care of simple error checking... and be nice...other wise noone will want to help you.
LOL...be nice? How am I suppose to be nice to a post that is disrespectful. It's ok, I don't take offense to it, as it's kinda hard to insult someone who lacks maturity and a grasp of what others are explaining clearly. It's like arguing with a 7 yr old retard (your words not mine).....no one wins! LOL! With that being said, it seems like you just provided an alternative way to append keywords (from source URL) utilizing one parameter to a link onpage, which is exactly what the script in my original post executes (with less code). The code in my original post works very well, but I need it to recognize more than just one parameter (in that example it was 'w'). This was explained twice already. My 2nd post even reiterates this. It seems like you missed the concept completely, but thanks for an alternative way of doing exactly what I already have obtained. I stated in my original post that I am not a programmer, nor do I represent myself as one. I spend my time and efforts within the marketing arena and leave the code to programmers like yourself, who seem to grasp code, but lack any sort of manners and intelligence applied to things that actually produce a feasible income. You can now resume your daily ritual of playing World of Warcraft. Thank you for your time!
$query is an array containing all parsed parameters from the referring url. $_GET contains all the query parameters passed to your script. That is all you need to know. You are probably too new to PHP to understand. Everybody here tried to help you...but all you did was insult them. It's you that has the problem explaining your situation. It's you that has a problem understanding the answers.
You have to be the most incoherent programmer I have ever come across. I realize that I am not a PHP expert (mentioned it 3 times now), but I understand the code you are giving me. First off, according to your 1st post, it will pass any string that has the parameter 'kw', which is fine if I was using that id, but like I already stated sooo many times already, the script needs to recognize MULTIPLE parameters like 'id' and/or 'sub' and/or 'kw' etc, etc. Then pass the string after the parameter as you state above. Secondly, you didn't even finish the 2nd part of the process. You gave half of the answer, which wasn't even correct and did nothing that the original script couldn't already execute. As of now...the code you supplied above ( $parsed = parse_url($_SERVER['HTTP.....obviously not posting the entire code) paired with the script needed for the onpage links here: www.mydomain.com/goto/?kw=<?php echo "$query"; ?> doesn't even work. It returns the string "array" when passed. At least the script I copy and pasted here actually works. I just need an "expansion" of it per say. Anyways.....if you can't understand and comprehend what is stated above, you never will. There are a TON of programmers I can ask elsewhere or just hire.
You simply do not understand. I DO understand what you are trying to do. And I gave you the answer. $query is NOT a SCALAR variable. If you print $query it will simply print "array". You MUST identify the array key to access the keys value. So if the referring URL has the key "id" it will be held in $query['id'] and if you need to access the value of "sub" simply use $query['sub']. The code will parse the entire referring query string. Now that you know how to access the referring query keys and values you can then do whatever you need to do with them. It's not about me not understanding you. I understand you. You just don't understand the logic you are given. Hopefully now you do...
Yep, completely understand what your stating and I DO understand what your concepts you are conveying, but it still doesn't resolve the situation as your just re-explaining the same thing you did in your 2nd post. The problem you have yet to explain is what am I using on my "INTERNAL links". Again you only showed what code would be posted at the top of the page (yes I know how it works) here: $parsed = parse_url($_SERVER['HTTP_REFERRER'], PHP_URL_QUERY); parse_str($parsed, $query); print $query['kw']; Code (markup): Which I know in your example, makes 'kw' the key and everything afterward gets passed to my INTERNAL link AKA: affiliate link! So if I need the script to also recognize 'id' , 'sub' , keys, how is the code above changed? That's what you should have given. Again, I am not a programmer, in order for me to show you what I am asking, I am going to try to give an example, even though it may be wrong. Read below. $parsed = parse_url($_SERVER['HTTP_REFERRER'], PHP_URL_QUERY); parse_str($parsed, $query); print $query['kw'] ['id'] ['sub'] ['morekeys']; Code (markup): NOW....the second half to this explanation needs to be made about the "INTERNAL link". No mention of this has ever been brought up and is an integral part of this whole setup. According to the code I posted originally, the internal link is Now according to YOUR SETUP, what would it be? If I had to guess, it might be? Again, its probably wrong, but this would be the guess of a "non-programmer" if he wasn't getting help from one.
See you don't get it. lol.. I DID tell you how..i just didn't do it for you since I assumed you KNEW PHP. You keep on using $page.... $page isn't a variable in this example so it's null. Let's try this one more time... You have a referral link that redirects to your website: www.yahoo.com/?kw=hello You want to parse the referring URL's query string to fetch the value of "kw" which in this example is "hello", correct? You then want to create a different url with the same referring urls query "kw" and value attached. Right? You would use the below code to do JUST what I described: $parsed = parse_url($_SERVER['HTTP_REFERRER'], PHP_URL_QUERY); parse_str($parsed, $query); print "www.internalaffiliatelink.com/goto/?kw=" . $query['kw']; PHP: This example would print: www.internalaffiliatelink.com/goto/?kw=hello. So far is this what you are trying to do?
Your original question actually suggests something different than what you explained later on. Perhaps you are using incorrect terminology. Assuming you don't need the query string of the HTTP REFERRING URL (the previous REMOTE url that brings you to your current website) and you are ONLY looking to ACCESS your CURRENT parameters you would use $_GET['parameter key here'] So $_GET['w'] contains the value of the "w" key. $_GET['sub'] contains the value of the "sub" key. $_GET['kw'] contains the value of the "kw" key. ... etc... If you need to create urls using these keys on every page you would use: print 'http://yourdomain.com/whatever.php?kw=" . $_GET['kw']; Which would print http://yourdomain.com/whatever.php?kw=hello is the value of kw is hello.
No offence was intended, I was trying to help you. Lesson learnt, if you're going to be an ass to people who try to help, then don't use forums asking for help. A simple "Thanks but you misunderstand" would have sufficed.
He's ignorant. There's nothing more to say... He doesn't understand PHP but everyone else is stupid because he doesn't understand the responses...
Good lord Netstar.......you've managed to take an entire thread with a simple task and turn it into a huge fiasco, in which you still can't comprehend. I don't mind the insults as of now, but your lack of reading and comprehension of the English language is completely pathetic. I don't know HOW many times I have to keep repeating myself. In fact, I'm starting to think your playing dumb now, just to fuck with me. You also made the completely foolish statement: in which I told you on almost every single post, I am not a programmer, nor do I claim to be. Go read the statements above, as again, your failure of reading and/or comprehending anything I say seems to fail you frequently. Tell ya what, if I had to hire you as my programmer, you wouldn't last 1 day. You may have a grasp on code, but I think it takes up about 98% of your brain power as the other 2% is left behind to eat, shit, and sleep. LOL Regarding your post: I told you this whole time, I understand what your trying to do, the problem is you have no clue what I am explaining to you. It is like your not even reading my 3 explanations above. They are as clear as day and not hard to understand in the least bit. Again, pertaining to this post, in which your repeating for the 3rd time, the same shit you have already tried to explain. Quit repeating yourself man! I know what that code does and it DOES NOT do anything regarding the original request. IN FACT, and read this carefully it does EXACTLY the same thing as the ORIGINAL code I posted at the very top of this thread. It may do it in a different way, but it accomplishes the exact same goal. Why on earth would I want a different code that does the exact same thing as the original above? It really doesn't get more idiotic than this. In response to Holy shit! I think you FINALLY might have caught onto what I have been asking. It only took you 4 freaking tries! Damn!! So again, I will reiterate what I have already told you 3-4 times now....I need the script to recognize more than one key and then append whatever comes after. In your statement above, the keys are w, sub, and kw. So let's break this down so you can understand AGAIN (I feel like I have to spoonfeed a baby here). 1. What exactly is the script I place at the top of my webpage to get these 3 multiple keys? 2. What is my internal link going to look like with this script? Obviously print 'http://yourdomain.com/whatever.php?kw=" . $_GET['kw']; is not going to work. I'm sure you can easily print a small snippet to the end of my internal links like the example I give above: www.mydomain.com/goto/?subid=<?php echo "somethinggoeshere; ?> . BTW, your link above doesn't have closing "" so even coming from a non-programmer I can see a fault.
Hey there Chuck....nice of you to chime in. You wanted to start an argument when you began your statement: The code above does make sense, why else would I post it. It comes from another forum and it works in it's entireity. If the code didn't work or function, then maybe the code itself wouldn't make sense. Obviously that is not the case, as it is a legit working code. Secondly, you go further into explaining how the $GET script works, when I already have a working one posted, as your not even remotely trying to answer the question posted, your just trying to show you know php and explain something that has NO RELEVANCE on the initial question at hand. Your very transparent and just wanted to show how much of a programming nerd you were, which is great, but you were trying to be a smartass and no one......likes a smartass. So, you state you were "trying to help", but that was not your real intention. You were trying to down play my request and make yourself look more inferior. Your very transparent.
You're on your own. Noone is obligated to help you. And generally when someone does help you, you are nice in return. You do not insult them. You do not belittle them because you don't understand the answers. I have supplied you with the right answer. You just don't understand. You need to consult to a Basic PHP tutorial then come back here. As for me helping you...I'm done. You're a tool and you lack the ability to communicate.
Netstar, You really need to understand the basic concept of communication. When you start out by calling me an idiot and other vulgar terms, what do you expect back? I'm not the one who started the ugly dispute, but I will gladly finish it. I don't need your help in the least bit and can pay a programmer $5 if need be for a quick solution, I've been busy with other marketing aspects of my business. Not only do you not understand wtf your talking about, but you never even gave a solution, but more so an alternative to what I already had. What a waste of space. You didn't even come close to the "right answer" and your ability to comprehend anything past your delusional head would be a great feat for you. How old are you again? 12? I wish you could back up any and all your claims here, but like a small little retarded child, you make no point and keep repeating yourself, as if it will change anything. LOL
You are an idiot. 1.) for being rude to the two other members who tried to help you and 2.) for continuing to be rude to the ONLY member trying to help you as if it's an obligation of mine to help you with your code. So with that said...you don't want help. You just want to be rude and ridicule others because you feel foolish for not understanding the answers. So good luck figuring out your problem.