autotech Posted January 9, 2010 Share Posted January 9, 2010 I have this send-to-a-friend script with 2 issues: 1) When you open the form popup on a particular page, it includes the correct URL for that page (viewable on the popup form). But if you close it, go to another page, and open the popup again -- it shows the URL of the previous page (including it with the email). It holds the same URL no matter how many pages you go to and re-open the popup. Refresh does not help. You have to clear cookies, temp files, history (or one of those) in order to pull up the correct URL for the applicable page. 2) A random problem where sending the email does not include the page URL (blank where it should be on the email). A friend added: if ($refurl == '') $refurl = 'http://www.domain.com'; at line 61 of recform.php so users will at least get the homepage URL when this problem occurs. See attached files. Help on these problems would be greatly appreciated. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 9, 2010 Share Posted January 9, 2010 try this <? if(!isset($_SESSION['refurl'])) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; print $_SERVER['HTTP_REFERER'] . '<br />'; } $refurl = $_SESSION['refurl']; print $refurl; ?> Quote Link to comment Share on other sites More sharing options...
autotech Posted January 9, 2010 Author Share Posted January 9, 2010 I'm an amature at this stuff. Where should I put it? I replaced this: <? print $refurl;?> With this: <? if(!isset($_SESSION['refurl'])) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; print $_SERVER['HTTP_REFERER'] . '<br />'; } $refurl = $_SESSION['refurl']; print $refurl;?> in recform.php, but the problem is still there. Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 9, 2010 Share Posted January 9, 2010 I'm an amature at this stuff. Where should I put it? Thanks. replace this code <? if (!strpos($_SERVER['HTTP_REFERER'], "recform.php")) { $refurl = $_SERVER['HTTP_REFERER']; $_SESSION["refurl"] = $refurl; } else $refurl = $_SESSION["refurl"]; if ($refurl == '') $refurl = 'http://www.domain.com'; ?> with the code i posted. I have it debugging so it will print $_SERVER['HTTP_REFERER'] and $refurl, once you get the script working you can remove these two lines print $_SERVER['HTTP_REFERER'] . '<br />'; and print $refurl; Quote Link to comment Share on other sites More sharing options...
autotech Posted January 9, 2010 Author Share Posted January 9, 2010 The problem is still there, and the URL on the popup appears 3 times. I cleared cookies and files, and the 3 urls stopped appearing on the popup, but it still holds the first url when you go to other pages. Quote Link to comment Share on other sites More sharing options...
autotech Posted January 9, 2010 Author Share Posted January 9, 2010 Don't know if it make a difference, but the popup link is installed on each page as a Dreamweaver Library (.lbi) item: <a href="http://www.domain.com/email-page/recform.php" rel="nofollow" target="page" onClick="window.open('','page','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=515,height=660,left=50,top=50,titlebar=yes')"><img src="../images/tool-bar/email-button.gif" alt="E-mail Page" width="80" height="20" border="0" /></a> Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 9, 2010 Share Posted January 9, 2010 Do the links show up properly? Quote Link to comment Share on other sites More sharing options...
autotech Posted January 10, 2010 Author Share Posted January 10, 2010 The link shows up properly, but it still keeps the first URL where you opened the popup form. Go to another page and open the popup, and it will still display the URL from the previous page. There seemed to be no change with this installed: <? if(!isset($_SESSION['refurl'])) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; print $_SERVER['HTTP_REFERER'] . '<br />'; } $refurl = $_SESSION['refurl']; print $refurl;?> Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 10, 2010 Share Posted January 10, 2010 well refurl is just going to be the http_referer so the page that you saw before you saw that page. Quote Link to comment Share on other sites More sharing options...
autotech Posted January 11, 2010 Author Share Posted January 11, 2010 I don't know what you mean. If I open the form on one page it shows the correct URL for that page. Close the form. Go to any other page and open the form, it shows the previous page URL, instead of the current page where you just opened the form. There must be a fix??? Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 11, 2010 Share Posted January 11, 2010 Alright so what you said before is that the link wasn't showing up at all in the email, so assuming that now it is showing up in the email I need to understand what you want. From what I can tell you are saying that you want the $refurl variable to be the name of the page which the user visited before they opened the form. This should do the trick <? $ref_file = pathinfo($_SERVER['HTTP_REFERER'],PATHINFO_BASENAME); $self_file = pathinfo($_SERVER['SCRIPT_FILENAME'],PATHINFO_BASENAME); if($ref_file != $self_file) { if(!isset($_SESSION['refurl'])) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; } else { if($_SESSION['refurl'] != $ref_file) { $_SESSION['refurl'] = $ref_file; } } } $refurl = $_SESSION['refurl']; print $refurl; ?> Quote Link to comment Share on other sites More sharing options...
autotech Posted January 11, 2010 Author Share Posted January 11, 2010 Nope, it's still showing the URL of the first page where you open the form. If you go to another page, open the form again, it shows the previous page URL, instead of the current page URL. Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 11, 2010 Share Posted January 11, 2010 Alright now copy everything that this next script prints to the screen and paste it here. I've set up some checks so we can see what's happening. <?php $ref_file = pathinfo($_SERVER['HTTP_REFERER'],PATHINFO_BASENAME); print "1). $ref_file \r\n"; $self_file = pathinfo($_SERVER['SCRIPT_FILENAME'],PATHINFO_BASENAME); print "2). $self_file \r\n"; if($ref_file != $self_file) { if(!isset($_SESSION['refurl'])) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; print "3). $_SESSION['refurl'] \r\n"; } else { if($_SESSION['refurl'] != $ref_file) { $_SESSION['refurl'] = $_SERVER['HTTP_REFERER']; print "4). $_SESSION['refurl'] \r\n"; } } } $refurl = $_SESSION['refurl']; print "5). $refurl \r\n"; ?> Quote Link to comment Share on other sites More sharing options...
autotech Posted January 11, 2010 Author Share Posted January 11, 2010 Gives an error with that one: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/realwor1/public_html/email-page/recform.php on line 52 Quote Link to comment Share on other sites More sharing options...
crabfinger Posted January 12, 2010 Share Posted January 12, 2010 Try replacing print with echo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.