I’m not a PHP programmer and would like to ask how the following can be done, which I hope would be fairly simple in PHP. If somebody clicks on a link to my website and the link contains a specific ID. E.g. : www.mywebsite.com/click?ID=1234 The ID (in this case 1234) needs to be passed on to links on my webpage dynamically when my page loads. E.g. a link on my website needs to change to www.someothersite.com/click?ID=1234 Anybody who can assist me on this?
Such variables are stored in $_GET[], so try this: <?php echo '<a href="yourlink.com/click?ID='.$_GET['ID'].'">some text</a>'; ?> PHP:
Make sure your page has a .php extension, it does not work if pg is named .html You can drop that variable anywhere in the page by just pasting <? echo $_GET['ID'] ; ?> whereever you want it to go. The above commenter answered your question about building the link, but you might want to use it in other places. Just drop the above everywhere you want to see 1234 Hope this helps
I have a website with many links like that Basicaly the 2 posts above described well what you should do but I used a little different method so Contact me trough PM if you need more help
When passing data about you have three ways of doing it and each has best use and not so good use. For example if you have a script that serves up pages index.php?page=1 then the $_GET technique works very well. You can stack several items like this index.php?page=1&chapter=7&somevar=something&book=my-book-of-stuff If you want to be flashy you can make the url look like this index.php/page/1/chapter/7/somevar/something/book/my-book-of-stuff but then you will need to grab all of it and use explode to create an array and then work the array to work out the values you've got (lots of work). The second option is to pass data as form data $_POST is then the fellow you use it works the same way as before but google can't read it. (I understand). The third option is good for passing things like user ID. (it's actually two methods but they get grouped as one). cookies and session. Session lasts until you close the browser and cookie lasts as long as you want it to.
If you don't want people to see the number, it might be better to use SESSIONS to keep track of the number. It will look cleaner as well; asuming you know what sessions are as a php coder.