SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick code question...

    Well, I am making a advetising program, and when the people either click the text link, or the image, I want that <a href="...">...</a> code to add clicks into a txt file. Like say the link already has 14 clicks, and someone clicks the text link, than it would display it has 15 clicks, and so on and so on...

    Can someone please help me on this Thanks!

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you'd want the link to point to a PHP script like:

    <a href="http://www.test.com/links.php?id=1&url=http://www.testtwo.com">test</a>

    then fopen the file with that ID number, update the contents, and forward them out to wherever the url= setting is...
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that I understand that. I will just have to work on that I guess. I will probably ask some more questions about it though later on...

  4. #4
    SitePoint Member SPTony's Avatar
    Join Date
    Sep 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I would do it like eny said.

    For the clicks i would have it show in the link like google.com?id=15

    and have the clicks go into a database or if you want text file that you have. If someone types in google.com?id=1000 it wil automatically know that the next one is 16 so it redirects it to google.com?id=16.

    Understand?

  5. #5
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, let me ask something more about this...

    Say I have a text file, and I have on the text file "12" already in there. Alright, now that I have the on there, say I have a link to google.com on my page, and I would like it to link to google.com. What would I make the link?

    I am really not understanding this at all...

  6. #6
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would need to make the link, a link to your script, with the URL that you want to go to, a parameter, so it knows where to go.

    Example of how this would work:

    1. Make a link like say: <a href='link.php?url=http://www.google.com'>Google</a>
    2. In link.php, you can run the script to increment the counter. Then, at the end, you can use a redirect, to send the people to Google.

    So whats actually happening is that your not linking to Google, but to the script, and then the script sends them to Google. The url paramter can be any URL. Every link you want to be counted then, you would link to link.php?url=<URL Here>. Get it?

  7. #7
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, that explains a lot! But, just one more question...

    You said to use link.php as the script to increment the counter. But, would that be the link to the actual txt file, or would that be a link to the file that actaully does the adding to the text file? Like, the PHP file that does the adding to the txt file.

  8. #8
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Chicago
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The php does the adding to the text file. link.php should be the PHP script.
    Why's (Poignant) Guide to Ruby
    learn ruby with foxes, wizards, and chunky bacon

  9. #9
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, thanks! I will play with this now to make my cool script! Thanks again guys!

  10. #10
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, well, I use this code and the page that I want to go to is not loading. Here is the link that I have in the code:
    <a href="index.php?url=http://macsnpods.com" target="_blank">

    All it does is open up a new window (like I want it to) but it does not go to http://macsnpods.com (like it should)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •