Jump to content

Two actions on one button


Shamrox

Recommended Posts

I'm trying to improve the interactivity of a table of data. Currently, I have a column that displays an image and when clicked it takes the users to a form for emailing a reminder. Right next to that is a button that clears that record from the table when that reminder has been emailed.

I'd like to make it so that the user only has to click on the first button/image and as it takes them to the email form page, it also updates the record in the database and would clear it from the table based on the status field being set to Yes.

 

Currently here is my code, but it's not updating the database status field at all.

 

Here is the code for the two columns.

 <td align="center" class="tabletext"><a href="email_form.php?form=reminderconfirmation&registrarid=<?php echo $row_rs_reminder['registrarid']; ?>"><img src="images/icon_reminder.jpg" alt="Reminder Agreement" width="18" height="20" border="0" align="center"></a>
            <div align="center"></div></td>
          <td align="center" class="tabletext">
            <form id="clear" name="clear" method="post" action="<?php echo $editFormAction; ?>">
            <button type="submit"><img src="/mdwapp/images/0090_check.gif" alt="Check" width="12" height="12" border="0"></button><input name="registrarid" type="hidden" value="<?php echo $row_rs_reminder['registrarid']; ?>" /><input name="clearstatus" type="hidden" value="Yes" />
            </form>
	  </td>

 

Here is my code for submitting to database, but this doesn't do anything and not sure why.

<?php
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "clear")) {
  $updateSQL = sprintf("UPDATE spec_registrar SET clearstatus=%s WHERE registrarid=%s",
                       GetSQLValueString($_POST['clearstatus'], "text"),
                       GetSQLValueString($_POST['registrarid'], "int"));

  mysql_select_db($database_spectrum, $spectrum);
  $Result1 = mysql_query($updateSQL, $spectrum) or die(mysql_error());

  $updateGoTo = "dashboard.php?page=reminder";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
?>

 

Can someone tell me how I'd put the two functions together and get it to update the status? Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/90508-two-actions-on-one-button/
Share on other sites

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.