-3
<?php
$con=mysqli_connect("localhost","root","","ok_db")or die(mysqli_connect_error());
$output = 'arslan';
// collect
if (isset($_POST['search'])) {

    $searchq = $_POST['search'];
    $searchq = preg_replace("#[^0-9a-z]#i","",$searchq);

    $query = mysqli_query($con,"SELECT * FROM user_data WHERE fname LIKE '%$searchq%'") or die("Could not search.");
    $count = mysqli_num_rows($query);
    if($count == 0) {
        $output = 'No results found.';
    } else {
        while($row = mysqli_fetch_array($query)) {
            $itemname = $row['fname'];
            $description = $row['lname'];
            $image = $row['id'];

            $output .= '<div>'.$itemname.' '.$description.'</div>';
        }
    }
}
else{

   echo "no" ;

}
?>

<html>
<head>
<title>searching</title>
</head>
<body>
<form action="search.php" method="POST">
    <input type="text" name="search" placeholder="Search">
    <input type="submit" value=">>" />
</form>
</body>

<?php
print $output;
?>
</html>

This code works fine on my local host (XAMPP) but does not echo anything out in PhpStorm, the isset function not working there and always shows the output "no".

Is something wrong with my PhpStorm settings because it runs fine on localhost?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 3
    when you say phpstorm doesnt show anything, do you mean youre using the 'view in browser' option? if you are that just loads the file locally and will not render any php as it has no server to go through. – DevDonkey Sep 21 '16 at 10:49
  • You must be using PhpStorm's own built-in simple web server .. which ATM has issues with handling POST requests. Just configure PhpStorm to use your Apache from your XAMPP installation -- http://stackoverflow.com/a/34787827/783119 . What's the URL you see in the browser address bar when this does not work? – LazyOne Sep 21 '16 at 10:50
  • BTW -- technically `isset` is not a function but language construct that behaves like function – LazyOne Sep 21 '16 at 11:02

1 Answers1

0

PHP STORM is an IDE for writing your code and has no effect on this.

I would suggest doing

print_r($_POST['search']);

and making sure it is actually filled in, possibly a typo.

virepo
  • 320
  • 5
  • 22