I have field 'groupname' encrypted in my db table and would like to decrypt it for search results using the following
$group = openssl_decrypt($row2[groupname], $method, $key); but along the way something is failing and the profile heading doesn't display at all. The field ''groupname' populates search results in a search field as you type it in the search box.
if(isset($_REQUEST["term"])){
$queryg = "SELECT * FROM table WHERE groupname LIKE ? AND identify = 2 AND reg = 1";
if($stmt = mysqli_prepare($con, $queryg)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_term);
// Set parameters
$param_term = '%' . $_REQUEST["term"] . '%';
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
// Check number of rows in the result set
if(mysqli_num_rows($result) > 0){
echo '<p class="resulthead">Profiles</p>';
// Fetch result rows as an associative array
while($row2 = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<p><a href=\"/public/" . $row2["memberid"] . "/" . openssl_decrypt($row2[groupname], $method, $secret_key) . "\">" . openssl_decrypt($row2[groupname], $method, $secret_key) . "</a></p>";
}
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($con);
}
}
// Close statement
mysqli_stmt_close($stmt);
}
// close connection
mysqli_close($con);
?>