arok
arok

Reputation: 1845

unable to pass a parameters to php in a form?

I have the html form but i am unable to pass the hidden parameter to the next page.i want to pass the hidden clientid to the next page but i am unable to pass.

My Form

<form action = "clientpricelistexport/exp_to_excel.php" method = "post">

<input type="hidden" name="clientid" id="clientid" value="<?echo $clientid;?>" >

<table  id="CPH_GridView1">

    <tbody >
<?php   

  $dbHost = 'localhost'; // usually localhost
 $dbUsername = 'xxx';
 $dbPassword = 'xxxx';
  $dbDatabase = 'xxxx';
  $db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
  mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");
$clientid=$_GET['clientid'];
if($clientid!=""){
$sql = mysql_query("SELECT `clientid` , `clientname`
FROM `client_list`
WHERE `clientid` = '$clientid'");
while($rows=mysql_fetch_array($sql))
{
if($alt == 1)
        {
           echo '<tr class="alt">';
           $alt = 0;
        }
        else
        {
           echo '<tr>';
           $alt = 1;
        }

echo ' 
        <td id="CPH_GridView1_clientid" style="width:140px" class="edit clientid '.$rows["id"].'">'.$rows["clientid"].'</td>
        <td id="CPH_GridView1_clientname" style="width:160px" class="edit clientname '.$rows["id"].'">'.$rows["clientname"].'</td>      

                <td style="width:65px" class="deleteclientlist '.$rows["id"].'"></td>

        </tr>';


}
}
?>
</tbody>
</table>

<input type="submit" value="Export"  class="export">

   </form>

and i am try to print it in next page like this.

$clientid=$_GET['clientid'];
print $clientid;

but it not printing anyone tell me where i am going wrong thanks.

Upvotes: 0

Views: 249

Answers (4)

Fyntasia
Fyntasia

Reputation: 1143

You're using method="POST". To retrieve data from a form using this method you have to use:

$clientid = $_POST['clientid']

($_POST)

or

$clientid = $_REQUEST['clientid']

($_REQUEST)

Upvotes: 1

ylerjen
ylerjen

Reputation: 4249

you specify the method post in your form and get it from the $_GET. Change it to

$clientid=$_POST['clientid'];

Upvotes: 0

Mohan Kumar
Mohan Kumar

Reputation: 334

User $_REQUEST['clientid'], it will handle both get and post request.

Upvotes: 0

Mandar
Mandar

Reputation: 66

You are using <form action = "exp_to_excel.php" method = "post"> as method "POST" but accessing the values with "GET"

try

$clientid=$_POST['clientid'];
print $clientid;

Upvotes: 2

Related Questions