Results 1 to 4 of 4

Thread: using hidden form fields..

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default using hidden form fields..

    hi..
    i want to know that cnai pass agrguments by hidden form fields from 1 page to other?
    but i dont have any submit button on my page..
    means no form is being submitted , but i need a value of 1 page to other?

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

    Default

    Hidden form fields can only be sent when a form is submitted.

    You can try get variables if the user is going to the new page from a link, maybe.

    The best way to do this is with sessions (or, maybe, cookies).

    It is fairly simple:
    session_start(); (at the TOP of your pages)
    $_SESSION['hiddenfieldname'] = 'hiddenfieldvalue';
    Then on any page during the same visit:
    echo $_SESSION['hiddenfieldname'];

    The only problem is that will stay saved until you change it, so not just for the next page. But if you want to change it, just do $_SESSION['hiddenfieldname'] = ''; (now it's blank).
    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

  3. #3
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    ys its good idea to use SESION, BUt the problem iam facing with SESSION is that, i need to sum the value of SESSION variable on every page, as on 1st page its 10 on next page 1st 20, and so on

    but when a same page is refreshed, the value is gets ioncremented on the same page
    means on page no 1 value is 10, when page is refreshed, the value on page no 1 becomes 20, again refresh value=30.. and so on..


    so session variable are also not useful here

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

    Default

    Session variables would work, if you designed the system differently.
    For example, you could also track when a user enters a page for the first time using sessions:
    $_SESSION['visitedpages'][] = __FILE__; //add the current filename to the visited pages list

    Then you can only increment the value if they have not been to the page before:
    if (!in_array(__FILE__,$_SESSION['visitedpages'])) { .......... }


    However, in this case it sounds like you should use get variables: they are part of the url, so that way you know what page you are on.
    Alternatively, if you just want separate pages, you can manually code a value at the top of each page:
    at the top of page 1: $page = 1;
    at the top of page 2: $page = 2;
    and do that for every page
    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
  •