Passing variable from URL to hidden field in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dshard
    New Member
    • Nov 2008
    • 1

    Passing variable from URL to hidden field in form

    Hello,

    I have a site with PHP pages. I need to be able to pass a variable from a URL similar to http://yoursite.com?af filiate=CD123, the variable being "CD123".

    This ID needs to be included in a hidden form field in an online booking form.

    My PHP experience is limited so the easier the better.

    Thanks.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you can echo this variable like
    [PHP]echo "<html_tag> " . $_GET['affiliate'] . "</html_tag>";[/PHP]
    a better way would be using a session
    [PHP]// you may have to do the usual checks for variable validaty
    session_start() ;
    $_SESSION['affiliate'] = $_GET['affiliate'];
    // further code

    // somewhere else (another php page):
    session_start() ;
    $var = $_SESSION['affiliate'];
    myfunction($var ); // do whatever is to be done with that variable[/PHP]
    further information on sessions can be found at the php.net session manual

    regards

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Originally posted by dshard
      Hello,

      I have a site with PHP pages. I need to be able to pass a variable from a URL similar to http://yoursite.com?af filiate=CD123, the variable being "CD123".

      This ID needs to be included in a hidden form field in an online booking form.

      My PHP experience is limited so the easier the better.

      Thanks.
      That's great. Good luck with that.

      But without any effort yourself (overlooking Dormilich's post) we are unable to help, as we do not just hand out working code but help others with theirs.

      Moderator.

      Comment

      Working...