SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Anywhere
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    conveying the session

    I have the above variable that act as a link to a previous page

    $_SERVER[HTTP_REFERER]

    The session cannot saved clicking on the above link.

    What is wrong?

    Here is my code

    PHP Code:

    <? session_start(); 

    include(
    "$_SERVER[DOCUMENT_ROOT]\newsdb_name.php"); 
    include(
    "$_SERVER[DOCUMENT_ROOT]\newsformat_text.php"); 
    mysql_connect(serverusernamepassword); 
    mysql_select_db(db_name); 


    $result=mysql_query("SELECT *, DATE_FORMAT(date_posted, '%e-%m-%Y')AS date_posted, DATE_FORMAT(last_update, '%e-%m-%Y')AS last_update FROM post WHERE postid='".$_GET['post_id']."'"); 

    $row=mysql_fetch_assoc($result); 

    $result1=mysql_query("SELECT category FROM categories WHERE categoryid='$row[categoryid]'"); 
    $row_service=mysql_fetch_assoc(mysql_query("SELECT service FROM users u, post p WHERE u.userid=p.userid AND postid='$_GET[post_id]'")); 
    $row1=mysql_fetch_assoc($result1); 
    ?> 



    <table bordercolor="black" align="center" valign="center" border=0 width="90%"> 

    <tr> 

    <td align="left" class="text"> 
    <b>category: </b><?echo $row1[category]?> 

    <td align=right class="text" > <b>date:</b> <?echo $row[date_posted?> 
                                      </td> 

    </td></tr><tr> 
    <td colspan="2" align=left class="text" ><b>service:</b> <?echo $row_service[service]?> </td></tr> 

    <tr> 

    <td align=center class="text" colspan="2"><strong><big> 
                      <hr> 
                      <font color="#000066"><?echo $row[title]?></strong></big> 
                     <hr> </td></tr> 
                  <tr> 
                    <td  class="text" colspan="2"> 



    <? if(!empty($row['image'])) {$pic="<img src=\"../news/images/".$row['image']."\"><br><br>"; } else  {$pic="";} 
    echo 
    $pic
    echo 
    format_links($row['text'])."</td></tr>"

    if(
    $row[relevant_link]) { 
    ?> 
    <tr><td class="text" colspan="2"><br><br><b>link Link:</b><br><?echo format_links($row[relevant_link])?></td></tr><?
    ?> 
    <tr><td class="text" colspan="2"><hr><b>last_update: </b><?echo $row[last_update]?></td></tr> 
    </table> 


    <center><a href="<?echo $_SERVER[HTTP_REFERER?>">Back</a></center> 

    <? 
    mysql_close
    (); 

    ?>
    The problem focus on the last lines of the code ...$_SERVER[HTTP_REFERER]...

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Anywhere
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any idea?

  3. #3
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_SERVER[HTTP_REFERER] will not always be valid (search for recent posts regarding Nortan personal firewall) Perhaps you should use javascript to go back 1 in history?
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Anywhere
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, the javascript solution is unable to indulge my wish as when you click on such link the previous page has expired

  5. #5
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you control from whence they came, build the link / redirect with a link in the query string:

    PHP Code:
    echo "<a href='link2page.php?from={$_SERVER['PHP_SELF']}">The Link</a>"; 
    Then, if the user wants to go back, just build the appropriate link:
    PHP Code:
    echo "<a href='{$_GET['from']}">Back</a>"; 
    My name is Steve, and I'm a super-villian.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Anywhere
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I solved the problem by adding the SID in the Action in the form before the sessions starts. I hadn't observed that


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
  •