Retrieving Form Variables

A

Anonymous

Guest
Hi Pals

Hope you all are in the mist of cheers.I would like to share my doubt with you all and hope to be resolved soon.

As im generating the textbox(using input tags) automatically and later i would want to update the particular textbox value.

Example
Have to change the value of the desired textbox,let assume at default its value 1 and change as 3 later.

generated three text boxes along with the change link to the appropriate row.And i created the text box as txt1,txt2,txt3.If i click the change link of the second textbox (mean txt2, i generated this txt2 as txt as string and 2 as the index (like 'txt'.$index).I used the method as post in the form action.Where as in the change link passed the rowid as the parameter in the value of 2

In the action page i used the variable as $_POST['txt'.$_GET['rowid']]

But i didnt get the result,it shows the blank value.Anyone can give me the right way to substitute the callee variable to get the result.

Any help on this issue woud be greatly appreciated.

Cheers
SATHISH
 
Hi Swirlee,

Hereby attached the sample code of what i mean-by and the query asked in the previous post

PHP:
if ($_GET['action'] == "change") {
     $getId = $_GET['id'];
	 $getValue = $_POST['txt'.$getId];
	 echo "The value is -> " . $getValue;
	}

   $htmlFormat = "<form name = sample action = \"$PHP_SELF \" method = post>";
   $htmlFormat = $htmlFormat . "<TABLE>";
   
   for ($i=1;$i <= 3;$i++)
   {  
       $htmlFormat = $htmlFormat . "<TR><TD>" . $i . "</TD><TD><input type = text name = txt" . $i . " size = 2 value = 1></TD><TD> <a href = 'sample3.php?action=change&id=" . $i . "'> CHANGE </a> </TD></TR>";
   }
        $htmlFormat = $htmlFormat . "</TABLE></form>";
	    $htmlFormat = $htmlFormat . "<input type = button name = clear value = Reset onClick = \"javascript:location.href('sample.php')\">";
	    echo $htmlFormat;

Getting the result at $getValue,but it shows blank.If i made a mistake of assigning the variable correct me.

Im a newbie to php,where as in ASP we use EVAL function for this scenario.

N.B : For the above snippet., the file name as sample.php. At initial the textbox value as 1 if i change the value as 4 and clcik the chnage link the value will come as "The value is ->" 4.(This is the requirement im looking for)

Any help would be greatly appreciated

Cheers
SATHISH
 
As I know, than you use
Code:
$_GET
to page send only GET and you cannot set and GET and POST in one time.....
sorry.....
the bast way use only one or GET or POST its first
second please do not use $PHP_SELF baes way use to $_SERVER['PHP_SELF']
in the third use not FOR use while
if you want to use Reset button use standard RESET in form, it's faster

good luck!
 
WiZARD said:
As I know, than you use
Code:
$_GET
to page send only GET and you cannot set and GET and POST in one time.....

Not so. You can have both GET and POST data in the same request.

in the third use not FOR use while

Why? There's no advantage to using while() over for().
 
swirlee said:
WiZARD said:
As I know, than you use
Code:
$_GET
to page send only GET and you cannot set and GET and POST in one time.....

Not so. You can have both GET and POST data in the same request.
ActuaLLY yes you may have but no every server may get from user both types and GET and POST......

swirlee said:
[
in the third use not FOR use while

Why? There's no advantage to using while() over for().

faster it's say Sasha and Anrew.....
 
WiZARD said:
swirlee said:
WiZARD said:
As I know, than you use
Code:
$_GET
to page send only GET and you cannot set and GET and POST in one time.....

Not so. You can have both GET and POST data in the same request.
ActuaLLY yes you may have but no every server may get from user both types and GET and POST......

swirlee said:
[
in the third use not FOR use while

Why? There's no advantage to using while() over for().

faster it's say Sasha and Anrew.....

I don't mean to be contrary, but I don't believe that either of these are facts. Could you give me some links?
 
Back
Top