Hi,
I`m a newbie, so if I´m wrong to post my question here,
please don`t kill me right away, direct me to the right forum,
if you could please be so nice.
My problem:
I would like to create a general Feedback form, that applies
to all my webpages, so I can include a sentence at the bottom,
like for feedback, please click here
When the user clicks on the link, the user should be take
to a new page (my feedback page) and the name of the page,
from which the user came should be taken with the jump to the
feedback page.
How can I do that with php?
I want to include the name of the originating page in the feedback
form, so I don`t have to write a form for each page...
The feedback form will include a Subject line, into which I would like
to put/parse the name, but I guess that`s the next step.
Help would be nice, or if you could point me to a similar tutrial if available.
Bye
Nike
Passing the current filename to a new file
Moderator: General Moderators
$_SERVER is a superglobal that is set for you by PHP on script-entry (check the manual and your php-version if this appropiate for you)
$_SERVER['HTTP_REFERER'] (if set) contains the string the client transmitted.
If the link to your script the user activated is i.e. on the page http://my.host/whatever.html $_SERVER['HTTP_REFERER'] should contain 'http://my.host/whatever.html'
put in your feedback.php to see how it works.
Next step is to create a form for the feed back. try something likein your feedback.php. If HTTP_REFERER has been given, it's value ('the calling page') is kept as hidden value within the form. If not, a text field where the user can type the url is added to the form.
Just as remark: it's (obviously) only a very basic code-snippet.
i.e. in the print-statement you should encapsulate $_SERVER['HTTP_REFERER'] with htmlentities(), in 'processing' script you may check the url (could be something that does not belong to you) and so on and so on
$_SERVER['HTTP_REFERER'] (if set) contains the string the client transmitted.
If the link to your script the user activated is i.e. on the page http://my.host/whatever.html $_SERVER['HTTP_REFERER'] should contain 'http://my.host/whatever.html'
put
Code: Select all
<?php
if (isset($_SERVERї'HTTP_REFERER']))
print 'HTTP_REFERER = '.$_SERVERї'HTTP_REFERER'];
else
print 'no HTTP_REFERER given';
?>Next step is to create a form for the feed back. try something like
Code: Select all
<html><body>I'm sorry you have something to complain about.....bla bla bla
<form action ... method ... >
<input name="source" <?php
if (isset($_SERVERї'HTTP_REFERER']))
print 'type="hidden" value="'.$_SERVERї'HTTP_REFERER'].'"';
else
print 'type="text";
?> />
<br/>
<input name="desc" type="text" />
...
</form>
...Just as remark: it's (obviously) only a very basic code-snippet.
i.e. in the print-statement you should encapsulate $_SERVER['HTTP_REFERER'] with htmlentities(), in 'processing' script you may check the url (could be something that does not belong to you) and so on and so on
Thank you - exactly what a newbie needs ;-)
Hi,
thank you very much.
Your explanation and example really
helped me get on with what I am planning to code.
Sometimes it`s those very obvious (for the trained)
little easy things, that are the hardest for the newbies
Thanks again.
Bye
Nike
thank you very much.
Your explanation and example really
helped me get on with what I am planning to code.
Sometimes it`s those very obvious (for the trained)
little easy things, that are the hardest for the newbies
Thanks again.
Bye
Nike