Jump to content

Email to a friend script problems


autotech

Recommended Posts

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]

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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;?>

Link to comment
Share on other sites

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???

Link to comment
Share on other sites

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;
?>

Link to comment
Share on other sites

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";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.