-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
22 lines (19 loc) · 704 Bytes
/
Copy pathsearch.php
File metadata and controls
22 lines (19 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
session_start();
$query = $_GET['search'];
$q = "SELECT * FROM product WHERE Product_Name Like '$query%'";
try {
$connection = new PDO("mysql:host=localhost;dbname=security", "root", "rewind95591");
// $connection = new PDO("mysql:host=localhost;dbname=security", "root", "");
// set the PDO error mode to exception
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $connection ->prepare($q);
$result->execute();
$result = $result->fetchAll();
$_SESSION['search_res'] = $result;
header('location: search_res.php');
} catch(PDOException $err) {
echo "Failed to connect to database";
$connection = null;
}
?>