0

Here I need your help, I have developed a phone book management system and I want to search for contacts of the person using the username in the session. Here is the search code I have but it returns all values even those that do not belong to that person.

if (isset($_POST['sea'])) {
    $value=$_POST['sear'];
    $get=mysql_query("select * from contacts where iduser='".$_SESSION['username']."' || mno like '%$value%' || wno like '%$value%' || nname like '%$value%'"); 
    while ($got=mysql_fetch_array($get)) {
        echo "<tr><td><img src=".$got['image']." width='100px' height='50px'></td><td>".$got['fname']."</td><td>".$got['lname']."</td><td>".$got['nname']."</td><td>".$got['mno']."</td><td>".$got['email']."</td><td id='print'><a href=''>More</a> |  <a href=''>Edit</a> | <a href=''>Delete</a></td></tr>";
    }               
}

Help me please, thank you.

Murad Hasan
  • 9,565
  • 2
  • 21
  • 42
  • I see two POST variables, sea and sear, is that right? which one is the search term? – Webomatik May 05 '16 at 17:39
  • The `mysql_*` functions in PHP are deprecated and shouldn't be used. Please read [Why shouldn't I use mysql_* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) for information on why and what to replace them with. – Matt Raines May 05 '16 at 17:59
  • The "sear" is the search button name and the "sea" is the name of the search textbox name – Ssekiziyivu Godfrey May 06 '16 at 04:29

0 Answers0