Welcome to WebmasterWorld Guest from 54.162.129.32

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

http referer

making forms return to the referring page

     

hydrolix

9:19 pm on Sep 30, 2002 (gmt 0)

Inactive Member
Account Expired

 
 


After reading a page, users can click thru to a feedback form. Once they have filled out the form, I would like the user to be taken back to the referring page AND the url of the referring page to be included in the email that is sent to me.

I think I've figured out I can use http referer but I don't know how to reference it in my form. Any ideas?

10:59 pm on Sept 30, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


Welcome to WebmasterWorld, hydrolix.

This sounds more like a job for server-side scripting, especially including the referer in the email you get sent to you. So, I'm moving the thread over to the Scripting forum. I'm sure the folks that hang out there will be chock full of ideas!

12:16 am on Oct 1, 2002 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


Welcome to WebmasterWorld, hydrolix

What scripting language does your form processor use?

For php I would use the $HTTP_REFERRER. You have to keep in mind that you may not always get a referrer from every browser. You could also pass it to the form. Put it in the form link on the page. You would have to script that as well. You could have a link like.

www.somedomain.com/feedback.html?page=article12

Something like that, but the actual implementation would have to do with what language you are using or have available.

3:21 pm on Oct 1, 2002 (gmt 0)

New User

10+ Year Member

joined:Aug 23, 2002
posts:25
votes: 0


I would try not to rely on the http_referer variable if possible, as Jatar says it's not always that reliable.

Presuming it's PHP, you could do something like this:

On the original page


<a href="feedback.php?page=<?=$PHP_SELF?>">Comment on this page</a>

At the top of feedback page after they've filled in their comments (must be above all HTML and white space).


<?
if (isset($submit)) {
$comments = $_POST['comments'];
$comments .= "\n\nSent about the page $page";
mail ("me@example.com", "Subject", $comments);
header ("location: $page?sent=yes");
}
?>

You could then use the $sent variable to display a message that their comments have been successfully received. You might also want to do some checking to make sure the $page variable hasn't been tampered with.