Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Search don’t return error

Discussion in 'Misc WordPress Requests' started by Soumanta Bhowmick, Oct 30, 2017.

  1. Soumanta Bhowmick

    Guest

    Reply To: Search don’t return error, by Soumanta Bhowmick

    <?php
    // you must check if $_POST['nome'] variable is set
    if( isset( $_POST['nome'] ) && !empty( $_POST['nome'] ) ) {
    $nome = $_POST['nome']; // try some validation here, like sanitize_text_field()

    if (is_user_logged_in()):

    global $wpdb;

    $customers = $wpdb->get_results("SELECT * FROM wp_clientes where Nome_Cliente LIKE '%".$nome."%' ");

    if($customers >= 1){
    echo "<table>";
    foreach($customers as $customer){
    echo "<tr>";
    echo "<td>".$customer->Nome_Cliente."</td>";
    echo "<td>".$customer->Email_Proprietario."</td>";
    echo "<td>".$customer->Nome_Empresa."</td>";
    echo "<td>".$customer->Pagamentos."</td>";
    echo "</tr>";
    }
    echo "</table>";
    } else {
    echo "Nothing!";
    }
    else:
    echo "Sorry, only registered users can view this information";
    endif;
    }

    To print $wpdb errors, use $wpdb->print_error()

    Reply To: Search don’t return error
     
    #1

Share This Page

Web Hosting