ProblematicSolution ProblematicSolution - 4 months ago 6x
MySQL Question

[PHP][Mysql]cant output anything, from my If statement. anyone knows what went wrong?

can u tell me whats wrong?
i want to ouput "yes" if match is found and "No Result" result if there is no result.. it seems that it dont ouput anything..

$output = NULL;

$st = $_POST['search'];
//Connect to the Database
$mysqli =NEW mysqli("localhost","root","","exam");

$search = $mysqli->real_escape_string($st);
echo $st;

//Query Database
$result = $mysqli->query("SELECT * FROM users WHERE name = '$search'");
if($result->num_rows > 0){
echo "yes";
echo "No RESULT";

<input type="TEXT" name="search"/><br>
<input type="SUBMIT" name="submit" value="search"/>


Your form doesn't specify method which defaults to GET and you're using $_POST arrays.

Therefore, you need to specify a "post" method for it.

Also, look into using PDO instead of raw mysqli connections for some very important benefits.