www.webdeveloper.com
Results 1 to 13 of 13

Thread: php loading a page clicking banner

  1. #1
    Join Date
    Jul 2010
    Posts
    8

    php loading a page clicking banner

    An user clicks on my banner that open my php page
    I want this page is loaded only clicking on the banner and not putting the 'web address directly in the browser
    It's possible?

  2. #2
    Join Date
    Mar 2008
    Posts
    73
    If I understand what you're trying to say. Yes it is possible. You'll need to look into a language called Ajax. If you don't mind reloading the page just include the page in the current page which has the banner and exit after checking that the banner was clicked.

  3. #3
    Join Date
    Mar 2010
    Posts
    672
    An easier route is just to lookup the referrer. It can be easily spoofed for those who want to, so it depends on how fool proof you want it.

  4. #4
    Join Date
    Jul 2010
    Posts
    8
    ok thank you can you post some example of code how to make ?
    thanks

  5. #5
    Join Date
    Mar 2010
    Posts
    672

  6. #6
    Join Date
    Jul 2010
    Posts
    8
    ok.. but this work if the banner is located in my page that i specify in script but i want the system working for banner located in any webpage on internet

  7. #7
    Join Date
    Mar 2010
    Posts
    672
    The banner is on their site correct? Thus when someone clicks on the banner from their site, it will have a referrer url of their site. If someone goes directly to the url, no referrer is sent.

  8. #8
    Join Date
    Jul 2010
    Posts
    8
    correct but i'm new in php can you help me with code ?

  9. #9
    Join Date
    Jul 2010
    Posts
    8
    PHP Code:
    <?php
        
    if($_SERVER['HTTP_REFERER'] == NULL) {
             echo  
    "access  denied";
             exit();
        } else {
            
    // Insert your page contents here.
            
             
    header("Location: http://site.com");
        }
    ?>
    i'm trying this if i type url in browser it give me access denied but if click banner
    it give me error coookie and don't go to page
    where is error?

  10. #10
    Join Date
    Mar 2010
    Posts
    672
    What do you mean by "it give me error coookie"? Does it give you a specific error? If so, what is that error? As far as i can see, nothing in the code sample you gave should be giving a cookie error.

  11. #11
    Join Date
    Jul 2010
    Posts
    8
    ok working it was a my mistake...
    ok but it can be easily spoofed
    A best alternative to $_SERVER['HTTP_REFERER'] what is ?

  12. #12
    Join Date
    Mar 2010
    Posts
    672
    The real question is how secure do you want it? Almost any method can be spoofed, its just a matter of how easily. Is this merely for an ad site? Or do you plan on using this for some truly secure information (in which case its a very bad approach)?

  13. #13
    Join Date
    Jul 2010
    Posts
    8
    not only for ad site but i want a minimal protection...
    i have tried also the define method: Suppose that i want protect page index.php containing a form
    i have inserted function define in link.php that is page linked by banner :
    PHP Code:
    <?php
    define
    ('_VALID_INCLUDE'TRUE);
    include(
    'index.php');

    /* rest of file */

    ?>
    and in index.php i have inserted:
    PHP Code:
    defined('_VALID_INCLUDE') or die('Direct access not allowed.'); 
    in this mode working but in browser url of link.php is visible and it's available for direct access to form
    Last edited by grigione; 07-16-2010 at 10:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles