Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Form Field

  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    67
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Form Field

    I dont know whether this is possible. I am looking to hide some information in a form text field. Is there anyway of doing this?

    Thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    I am looking to hide some information in a form text field.
    What's your ultimate behind this?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Jul 2010
    Posts
    67
    Thanks
    11
    Thanked 0 Times in 0 Posts
    I have 200 products and each has the same form and php... When the user hits "submit" I need to somehow know what product page it has come from.

  • #4
    Regular Coder
    Join Date
    Aug 2006
    Location
    Cardiff, UK
    Posts
    141
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Assuming that it's just that you don't want the field's contents visible, could you just store it in a hidden field?
    Code:
    <input name="fieldname" id="fieldname" type="hidden" value="variable that you're storing" />
    You can then read the contents of the field and insert or update the relevant column when the form's sent.
    If anyone asks my boss, this counts as work, okay?

  • Users who have thanked butlins for this post:

    joesruddock (07-21-2011)

  • #5
    New Coder
    Join Date
    Jul 2010
    Posts
    67
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Awesome Idea... Thanks!

  • #6
    New Coder
    Join Date
    Jul 2010
    Posts
    67
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Is there any way to have the URL in the hidden field without writing the URL out each time?

    Thanks

  • #7
    Regular Coder
    Join Date
    Aug 2006
    Location
    Cardiff, UK
    Posts
    141
    Thanks
    15
    Thanked 2 Times in 2 Posts
    If you're using PHP, you can use
    PHP Code:
    $_SERVER['php_SELF']; 
    to set a variable on the referring page, which you can then pass on.

    However, you might not need to save the whole path anyway. Assuming that your referring page path is something like "/folder/foo.php", that the page your linking to is "/folder/bar.php", and that your products are all saved with an ID number in your database, the referring page could be passing over "/folder/bar.php?productID=50". The only unique bit of information in that string is "50", so it makes more sense to just store that - it'll still tell you the product that they've been looking at.

    So, if that's the case, you could just add the ID number of the product from your database as a querystring to the link (or save it to a hidden field and post the contents of the form if you want the contents to be less obvious), from your referring page, and then get the data of which page it's come from that way.
    If anyone asks my boss, this counts as work, okay?


  •  

    Posting Permissions

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