Support » Requests and Feedback » Page Refreshes After Click Custom Button

  • Hello, I am having a problem with some custom PHP code on a WordPress site. I am using a plugin called PHP everywhere. I am putting the code below on the front page, all the code does it search the database to match a keyword and returns everything that matches that keyword.

    When I am in the “preview mode” for WordPress the code works perfectly, but when I try it on the actual site for some reason it reroutes it and says “Nothing Found” instead of displaying the results. I’m not sure why it says “nothing found” because it is only suppose to display the database results, but it seems like it may be searching the site? I’m pretty sure its wordpress, I put the code on my local computer and it worked fine.

    This is the code, please try to ignore the fact that I need to use a prepared statement for my query.

    <form method="post">
    <input action ="" type="text" name="search">
    <input type="submit" name="submit" value="Search">
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    $servername = "localhost";
    $username = "username";
    $password = "pass";
    $dbname = "db_name";
    $search_value = $_POST['search'] ?? '';
    $con=new mysqli($servername,$username,$password,$dbname);
        echo 'Connection Faild: '.$con->connect_error;
          if ( isset($_POST['submit']) )
      $sql="select word, sentence from word_tbl, sent_tbl where word like '%$search_value%' and sentence like '%$search_value%' limit 5;";
        echo '<br>word:  '.$row["word"];
        echo '<br>sentence:  '.$row["sentence"];
    echo "Button is not pressed, or form is not sent";

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Pie


    Hi @glitche

    I hope you are doing well.

    Just checking if you are still having the same issue from your end? I am able to pull it up fine. The page is asking for a word and it worked fine after entering any word.

    I suggest you clear your browser’s cache and check on it again. It could be just a caching issue.


Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.