Jump to content

[SOLVED] Form data not being posted to receiving page


doucie

Recommended Posts

Hi All,

 

I've got the following function to get data and display in a selection list and then post to the receiving page but it does not seem to work.  Please help.

 

<?php

 

function get_groups()

{

  $db=mysqli_connect('localhost','root','','debtnet');

  if(mysqli_connect_errno())

  {

      echo 'Could not connect to the database';

      exit;

  }

  $query="SELECT cclientgroup FROM groups ORDER BY cclientgroup";

  $result=mysqli_query($db,$query); ?>

  <form action="group_report.php" method="POST" />

  <select name="Client" id="Client" />

  <?php while($list=mysqli_fetch_array($result)){

      echo "<option value='".$list['cclientgroup']."'>".$list['cclientgroup']."</option>";

  }

  echo "<input type='submit' value='Get Report'/>";

  echo "</form>";

}

 

?>

 

The code for the receiving page is this:

 

<?php $client = $_POST['cclientgroup']; ?>

<div id="box">

Information relating to client group: <?php echo $_POST['cclientgroup']; ?>

</div>

Hey Doucie,

 

this should do the trick for you:

 

<div id="box">

Information relating to client group: <?php echo $_POST['Client']; ?>

</div>

 

'you just needed to insert the name of the field you passed to the next page (instead of the actual value, the value is what is echo'd out above)

 

enjoy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.