homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
http referer
making forms return to the referring page
hydrolix




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

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?

 

tedster




msg:1250169
 10:59 pm on Sep 30, 2002 (gmt 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!

jatar_k




msg:1250170
 12:16 am on Oct 1, 2002 (gmt 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.

hpche




msg:1250171
 3:21 pm on Oct 1, 2002 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved