Reputation: 241
I am making a search service on my page so the users are able to search for other users. I want to put the $_POST value in a SESSION and use the SESSION value in a SELECT for the search. This is what ive done, but it doesnt work - Seems like the SESSION doesnt have any value at all, but im not sure?
session_start();
include_once 'dbconnect.php';
if(isset($_POST['submit'])){
$search = $con->real_escape_string($_POST['search']);
$_SESSION['test'] = $search;
$test = $_SESSION['test'];
$result="SELECT * FROM users WHERE username LIKE '%$test%'";
...
Upvotes: 0
Views: 25
Reputation: 9508
You need to make sure you start your session with
session_start();
before you try to access the $_SESSION
variables and make sure the database you're connect to with $con
is set properly.
Upvotes: 1