ini_set("display_errors", "On"); error_reporting(E_ALL & ~(E_STRICT | E_NOTICE)); // grab db class and connect if (isset($_POST['submit'])) { require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/defines.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/postgredb.php"; $port = 5432; $persistent = 0; $db = new PostgreDB(FORMS_DATABASE, FORMS_HOST, $port, FORMS_USERNAME, FORMS_PASSWORD, $persistent); $db->Connect(); $firstname = addslashes($_POST['firstname']); $lastname = addslashes($_POST['lastname']); $email = addslashes($_POST['email']); $sql = "INSERT INTO contacts (firstname,lastname,email) VALUES ('{$firstname}','{$lastname}','{$email}')"; $db->ExecQuery($sql); $db->DBClose(); } ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Request Information</title> <style> body{ font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; font-size:12px; } p, h1, form, button{border:0; margin:0; padding:0;} .spacer{clear:both; height:1px;}
<?php include 'postgredb.php'; $output = "<div>No Result found.</div>"; if (isset($_POST['search']) && !empty($_POST['search'])) { $searchq = trim($_POST['search']); //$searchq = preg_replace("#[^0-9a-z]#i","",$searchq); $dbname = "df8k1m58fmo0qg"; $host = "ec2-54-83-36-176.compute-1.amazonaws.com"; $port = 5432; $user = "******"; $password = "******"; $persistent = 0; $dbdrv = new PostgreDB($dbname, $host, $port, $user, $password, $persistent); $dbdrv->Begin(); $sql = "SELECT * FROM company Where LOWER(First_Name) LIKE LOWER('%{$searchq}%') OR LOWER(Last_Name) LIKE LOWER('%{$searchq}%')"; if (!$dbdrv->ExecQuery($sql)) { die($dbdrv->Error()); } } ?> <form action="index.php" method="post"> <input type="text" name="search" placeholder="Search for members" /> <input type="submit" value="Search" /> </form> <table border="1" style="width:100%"> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th>