how to get hidden value?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chennaibala
Forum Newbie
Posts: 6
Joined: Thu Sep 10, 2009 1:51 am

how to get hidden value?

Post by chennaibala »

Code: Select all

<td width="25%"  align="left" scope="col"><input id="regid" name="regid" type="text" size="10" value="<?php 
                    include 'db0.php'; 
                    $query="SELECT LPAD(MAX(SUBSTR(id,4))+1,6,0) as NextNum FROM registrater"; 
                $result = mysql_query($query) or die ("Error in query: $query " . mysql_error()); 
                $row = mysql_fetch_assoc($result); 
                $num_results = mysql_num_rows($result); 
                //echo "NextNum:".$row['NextNum']."end|  ";
 
                if ($row['NextNum'] == null) 
                {
                    $reg1="abc000001";
                    echo "$reg1";
                }
                else
                {               
                    $regid=$row['NextNum'];
                    $reg="abc";
                    $reg1="$reg"."$regid";
                    echo "$reg1";
                }
                        
                    ?> "></td>
 
i used post method:
 
$hiregid=$_POST["regid"];
above is my actual coding....i can get my echo value,when type ="text"...when i change to type ="hidden"..i get value as null..
thanks in advance
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: how to get hidden value?

Post by Ollie Saunders »

i can get my echo value,when type ="text"...when i change to type ="hidden"..i get value as null.
That shouldn't affect it. What are you using to change the value? What might also be occurring as a result of making the value hidden?

The correct word for registrater is registrar, incidentally.
chennaibala
Forum Newbie
Posts: 6
Joined: Thu Sep 10, 2009 1:51 am

Re: how to get hidden value?

Post by chennaibala »

yes..when i insert in my table..it insert as empty field in that table..i dont know exactly..echo is for print purpose.....if its hidden..we cannot get that value frm hidden box...pls correct me if am wrong frds.. :(
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: how to get hidden value?

Post by Ollie Saunders »

Please write as correctly as you can. The more effort you put into your communication the more likely others will put effort into their replies, and your future will benefit from the practice. For instance, "pls" should be please, you should obey capitalization rules, and I don't even know what "frds" is supposed to mean. Now — on to your query:
if its hidden..we cannot get that value frm hidden box...pls correct me if am wrong frds..
Hidden values are instructions to the client to send a specific key value pair to the server, just as a normal text field will send a key value pair to the server depending on what the user types into the field. The only difference between a hidden field and a text field is that a hidden field is given no visual representation in the browser; meaning that, a normal user is given no opportunity to alter the value that will be sent.
yes..when i insert in my table..it insert as empty field in that table.
How are you inserting it into the table? You haven't shown that code.
i dont know exactly..echo is for print purpose
Yes, it is. You can use var_dump() for more detailed information. Feel free to use both echo and var_dump() during development to tell you things about what your code is doing; you can remove them later.
chennaibala
Forum Newbie
Posts: 6
Joined: Thu Sep 10, 2009 1:51 am

Re: how to get hidden value?

Post by chennaibala »

hi Ollie Saunders

sorry for my bad bad english....it not problem in inserting...problem found ,when i get value frm hidden text box is empty..if it text box,it return text box value to that variable..
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: how to get hidden value?

Post by Ollie Saunders »

You say sorry and continue to abbreviate unnecessarily. Oh well; I won't push this point any further.

Are you giving your hidden field a value?:

Code: Select all

<input type="hidden" value="monkeys" />
r4r4
Forum Newbie
Posts: 11
Joined: Thu Jul 02, 2009 12:01 am

Re: how to get hidden value?

Post by r4r4 »

I have a form, the javascript currently checks that the user can only enter a positive integer, i need it also to check that the integer the uses enters is lower than the hidden value. I can supply the current code if it will help.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: how to get hidden value?

Post by Ollie Saunders »

r4r4 wrote:I have a form, the javascript currently checks that the user can only enter a positive integer, i need it also to check that the integer the uses enters is lower than the hidden value. I can supply the current code if it will help.
I doubt it will.
Post Reply