View Full Version : using hidden form fields..
gurmeet
01-10-2010, 07:08 AM
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?
djr33
01-10-2010, 07:15 AM
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).
gurmeet
01-11-2010, 01:33 PM
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
djr33
01-11-2010, 07:18 PM
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
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.