CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Building Interactive UIs with ASP.NET Ajax: Rebinding Client-Side Events After a Partial Page Postback
  • Speed Up Repetitive Insert, Update, and Delete Query Statements
  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Scripting - Server Side (PHP, Perl, etc.)
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Scripting - Server Side (PHP, Perl, etc.) Discuss scripting on the server side. This can incldue PHP, Perl, and any server side scripting issues not covered in other forums.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 5th, 2009, 08:41 AM
    dremes dremes is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 2
    dremes is an unknown quantity at this point (<10)
    PHP Display Telephone Number On Referrer

    Please help

    I have used the php below to show a different telephone number in the header of the site depending upon where the visitor comes from. The code below works but looses the original referrer information upon click of own site links, defaulting the telephone number back to the generic number.

    Is there away to save it to the session, maybe the start session and save session is not done correct?


    Thanks for any help

    PHP Code:
    <?PHP
    session_start
    ();
    if(!isset(
    $_SESSION[&#8217;referrer’])){

    $referer = strtolower($_SERVER["HTTP_REFERER"]);

    if (
    strstr($referer,"site1"))
    {
    echo(
    "<h1>Telephone Number1</h1>");
    }
    else if (
    strstr($referer,"site2"))
    {
    echo(
    "<h1>Telephone Number2</h1>");
    }
    else if (
    strstr($referer,"site3"))
    {
    echo(
    "<h1>Telephone Number3</h1>");
    }
    else if (
    strstr($referer,"site4"))
    {
    echo(
    "<h1>Telephone Number4</h1>");
    }
    else
    {
    echo(
    "<h1>Telephone Number5</h1>");
    }
    $_SESSION[&#8217;referrer’] = $referrer; // store session data
    }?>

    Last edited by PeejAvery; November 5th, 2009 at 12:57 PM. Reason: Added PHP tags.
    Reply With Quote
      #2    
    Old November 5th, 2009, 12:58 PM
    PeejAvery's Avatar
    PeejAvery PeejAvery is offline
    Super Moderator
    Power Poster
     
    Join Date: May 2002
    Location: United States
    Posts: 9,597
    PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)
    Re: PHP Display Telephone Number On Referrer

    To retain session information, you need to be supplying a unique id to session_id() first, or using session_name() first.

    PHP Code:
    <?php
    session_name
    ('mySessionName');
    session_start();
    ...
    ?>
    __________________
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.
    Reply With Quote
      #3    
    Old November 5th, 2009, 02:02 PM
    dremes dremes is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 2
    dremes is an unknown quantity at this point (<10)
    Re: PHP Display Telephone Number On Referrer

    no that did not seem to fix the problem..... maybe i am doing it wrong!

    PHP Code:
    <?PHP
    session_name
    ('ref');
    session_start();
    if(!isset(
    $_SESSION[&#8217;referrer’])){

    $referer = strtolower($_SERVER["HTTP_REFERER"]);
    If you could please write / change the script, and the post it for all. I am new to this and would love a solution!

    Last edited by PeejAvery; November 5th, 2009 at 03:42 PM. Reason: Added PHP tags.
    Reply With Quote
      #4    
    Old November 5th, 2009, 03:44 PM
    PeejAvery's Avatar
    PeejAvery PeejAvery is offline
    Super Moderator
    Power Poster
     
    Join Date: May 2002
    Location: United States
    Posts: 9,597
    PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)PeejAvery has a reputation beyond repute (3000+)
    Re: PHP Display Telephone Number On Referrer

    Please start using [php] tags. Instructions to use them are found in the BB code link at the bottom left of the page.

    As for your problem, you aren't being clear. What about that snippet you just posted isn't working? Also, why are you using UTF-8 single quotes? Use basic ' single quotes or double quotes.

    Change...
    PHP Code:
    if(!isset($_SESSION[&#8217;referrer’])){
    To...
    PHP Code:
    if(!isset($_SESSION['referrer'])){
    __________________
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Scripting - Server Side (PHP, Perl, etc.)


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:13 AM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.