Results 1 to 2 of 2

Thread: Passing form data in URL using post method

  1. #1
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing form data in URL using post method

    Hi all,

    I am trying to pass data from a form field (to help adsense target ads) and I am running into a wall. I know it should not be that hard and there should be a script that can help.

    Anyway, here's the scoop. Normal form, using the POST method. I just want to take a form field (which will be the name of a state) and add it into the URL when the user clicks on submit.

    Anyone have any pointers or examples? Thank you in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Hmm.... Random guess, untested....

    <form action="page.php" method="post" onSubmit="this.action=this.action+'?var='+urlbit.value>
    <input type="text" id="urlbit">
    </form>


    the problem is that it relies on javascript, so it won't work if the user doesn't have that enabled. So... make sure there's some sort of fallback. If possible, have a server side backup.

    If possible, you may wish to just set the action of the form with a default get variable, like action="page.php?var=1". That might just solve your whole problem, but if not, at least you have a default value if JS is disabled.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •