Jump to content

[SOLVED] sending querystring vars via form action


neridaj

Recommended Posts

Hello,

 

Is there a way to send multiple vars via the querystring using form action without javascript? I have a form containing a table of users which I would like to add "Create" and "Update" buttons for each user to create and update invoice data. I would like to be able to click on the respective buttons to send the "create" or "update" value along with the username.

 

function display_invoice_table($result)
{
  // display the table of users
  // set global variable, so we can test later if this is on the page
  global $invoice_table;
  $invoice_table = true;
  // $action = create or update
  // $user = username
?>
  <br />
<?php
  echo "<form name='invoice_table' action='create_invoice.php?a=$action?u=$user' method='post'>";
  echo '<table cellpadding="0" cellspacing="0" align="center" border="1">';
  echo "<tr><td><strong>User</strong></td>";
  echo "<td><strong>Invoice?</strong></td>";
  echo "<td><strong>First Name</strong></td>";
  echo "<td><strong>Last Name</strong></td>";
  echo "<td><strong>Agent Name</strong></td>";
  echo "<td><strong>Email</strong></td></tr>";
  while ($obj = mysqli_fetch_array($result)) {
        printf ("<tr><td>%s</td><td><input type='submit' name='create' value='Create'></td><td><input type='submit' name='update' value='Update'></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
	$obj['username'], $obj['username'], $obj['first_name'], $obj['last_name'], $obj['agent_name'], $obj['email']);
    }
  mysqli_free_result($result);
}
?>

Thanks for any help,

J

i wouldn't use a form here. just have buttons with onclick events for A tags with href attributes that point to the page:

function display_invoice_table($result)
{
  // display the table of users
  // set global variable, so we can test later if this is on the page
  global $invoice_table;
  $invoice_table = true;
  // $action = create or update
  // $user = username
?>
  <br />
<?php
  echo '<table cellpadding="0" cellspacing="0" align="center" border="1">';
  echo "<tr><td><strong>User</strong></td>";
  echo "<td><strong>Invoice?</strong></td>";
  echo "<td><strong>First Name</strong></td>";
  echo "<td><strong>Last Name</strong></td>";
  echo "<td><strong>Agent Name</strong></td>";
  echo "<td><strong>Email</strong></td></tr>";
  while ($obj = mysqli_fetch_array($result)) {
        printf ('<tr><td>%s</td><td></td><td>',$obj['username']);
        //With a button
        printf ('<input type="button" value="Create" onclick="window.location.href=\'create_invoice.php?a=create?u=%s\';" />',$obj['username']);
        //With a link
        printf ('<a href="create_invoice.php?a=update?u=%s">Update</a>',$obj['username']);
        printf ('</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $obj['username'], $obj['first_name'], $obj['last_name'], $obj['agent_name'], $obj['email']);
  }
  mysqli_free_result($result);
  echo "</table>";
}
?>

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.