The aim is to take user comments from textarea of form and search for keywords and display matches. textarea data is inserted into sql database but is all on one line and not searchable and without formatting to reflect user real world input.Depending on match's a candidate for our services can be found.
I am using a DAO class to insert the comments into database, Here is the relevant code section:
function insert($zipcode,$address,$candidate,$remarks,$privacy,$source,$ip) { if ($zipcode.”==” || $address.” == ” || $candidate.” == ” || $remarks.” == ” || $privacy.” == ”) { return false;
and this to insert
$query = $this->db->prepare(‘INSERT INTO subscribers (zipcode, address, candidate,remarks,privacy, creation_date, source, ip) VALUES (:zipcode,:address,:candidate,:remarks,:privacy,:creation_date,:source,:ip)’); $query->bindParam(‘:zipcode’, $zipcode); $query->bindParam(‘:address’, $address); $query->bindParam(‘:candidate’, $candidate);
$query->bindParam(‘:remarks’, $remarks);
$query->bindParam(‘:privacy’, $privacy); $query->bindParam(‘:creation_date’, date(‘Y-m-d H:i:s’)); $query->bindParam(‘:source’, $source); $query->bindParam(‘:ip’, $ip); $query->execute(); $id = $this->db->lastInsertId(); return $id; } catch(PDOException $e) { //echo “Error: ” . $e->getMessage(); //exit(); return false; } } }