We have a feedback form in PHP which adds data to Oracle DB. We have noticed that some users are sending the same feedback multiple times which we want to avoid.
The best way for us is to check for some common fields already present in the Oracle table, if data is found, then just don't enter the data and pop up a message to the user.
I have used if
condition to check if the query returned any values and did a lot of trials and errors but didn't succeed. Below is my code, please check and suggest a suitable way to accomplish what I want.
$connect = oci_connect("ppusr", "welcome", "XX.XX.XX.XX/TR11",'AL32UTF8');
$sqlchk = "Select * FROM CUSTOMER_FEEDBACK WHERE CT_CUST_NAME=:CT_CUST_NAME , CT_CUST_NUMBER=:CT_CUST_NUMBER, CT_CUST_COMMENTS=:CT_CUST_COMMENTS ,CT_CUST_FEEDBACK_TYPE=:CT_CUST_FEEDBACK_TYPE, CT_CUST_LOCATION=:CT_CUST_LOCATION, CT_IP=:CT_IP";
$win12561 = iconv('windows-1256', 'utf-8', $sqlchk);
$stidchk = oci_parse($connect, $win12561);
oci_bind_by_name($stidchk, ':CT_CUST_NAME', $_POST['CustomerName']);
oci_bind_by_name($stidchk, ':CT_CUST_NUMBER',$_POST['CustomerMobile']);
oci_bind_by_name($stidchk, ':CT_CUST_COMMENTS',$_POST['Comments']);
oci_bind_by_name($stidchk, ':CT_CUST_FEEDBACK_TYPE', $_POST['Type']);
oci_bind_by_name($stidchk, ':CT_CUST_LOCATION', $_POST['Area']);
oci_bind_by_name($stidchk, ':CT_IP', $_SERVER['REMOTE_ADDR']);
oci_execute($stidchk);
$rowchk = oci_fetch_all($stidchk);
$ttno1 = $rowchk['CT_CUST_TTNO'];
if(empty($rowchk)) {
//...... insert data .........
}
else
{
//...... display message box .........
function function_alert($message) {
echo "<script>alert('$message'); location='https://www.google.com';</script>";
}
function_alert("Thank you but you have already submitted the feedback");
}
Thanks.