Count searches by logged in user
I need to count each time someone uses a search form.
To update the data, I am using:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["button2"])) && ($_POST["button2"] == "form2")) {
$updateSQL = sprintf("UPDATE members SET currentcount = currentcount + '1' WHERE mID=%s",
GetSQLValueString($_POST['nothing'], "int"),
GetSQLValueString($_POST['mID'], "int"));
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($updateSQL, $conn) or die(mysql_error());
$updateGoTo = "search-result.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
Unfortunately, not only am I not counting the search, but the search form does not load the results page so I assume it is a triggering problem, but I have not been able to find a working trigger.
If I change the form post from <?php echo $editFormAction; ?> to the actual results page address the search produces the correct result, but if I do that I have no way of triggering the count. I have tried putting the count on the next page but that did not work either.
How can I trigger this count AND submit the search?