Need to copy an URL to another part of the page using PHP?

Discussion in 'PHP' started by Barry Scott, Nov 15, 2007.

  1. #1
    I have a form within my page, and it uses a formmail script to send the contents of the form to an email.

    I would like one of the hidden elements within the form to contain the URL or Title of the page that the form was sent from.

    I am using the same form across many areas of the site by loading it as an include, however, currently the form has an area called subject, i would like this subject to be dynamic and copy either the URL or the text between the <title></title> tags so i know where it was sent from.

    Is this possible and can someone help please?

    I store all my php includes away from the webroot if that makes any difference?

    Thanks

    :D

    EXAMPLE OF CODE

    <input type="hidden" name="subject" value="DYNAMIC PHP HERE" />
    Code (markup):
    I have tried things like this <?php getPageTitle(); ?> but my php doesn't stretch past <?php include :D
     
    Barry Scott, Nov 15, 2007 IP
  2. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    take a look at php_self or request_uri
     
    THT, Nov 15, 2007 IP
  3. Barry Scott

    Barry Scott Active Member

    Messages:
    183
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Superb thank you THT! Used the code below for anyone that's interested (it returns the URL).

    Thanks again :D

    <?php echo $_SERVER['REQUEST_URI']; ?>
    Code (markup):
     
    Barry Scott, Nov 15, 2007 IP