0
    <form id="form1" name="form1" method="post" action="  <?php
include("connect.php");
require("search2.php");
$username = $_SESSION['email'];
?>
">
        <p>
          <input type="text" name="search" id="search" value=""/>
              <input type="submit" name="btnSearch" id="btnSearch" value="SEARCH" />
      </p></form>

search2.php

      <?php
include("connect.php");
$username = $_SESSION['email'];
$name=$_POST['search'];
$query = mysql_query ("Select * from confirm_members where email = '$name'");
if(mysql_num_rows($query)==0)
        die ("User not found");
    else
{   
 while ($row = mysql_fetch_array($query))
{
 $members = $row ['email'];
 $location = $row ['imagelocation'];
 echo "<img src ='$location' width='100' height='100'>"."<a href= 'friendprofile.php?MemberID=$members'>".$members;
  } 
}


$search = mysql_query ("Select * from friends where user1 = '$username' && user2 = '$name'  ");
if(mysql_num_rows($search)==0)
echo "</a>"."&nbsp"."&nbsp"."<a href='addfriend.php?MemberID=$members'>"."Add as friend"."</a>"."</p>";         
    else
    {
 while ($row = mysql_fetch_array($query))
{
 $username = $row ['user1'];
 $name = $row ['user2'];
 $stat = $row ['status'];
} 

}
?>
2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by pritaeas
0

You did not show the message you got, so I'll guess $name=$_POST['search']; does not have a value set. The best way is to use the following construct:

$name = isset($_POST['search']) ? $_POST['search'] : '';
0

@pritaeas thank you for nyour reply.but when i did what you said it displays "User not found" even if i havent click the search button.what can i do?

Edited by makibao

0

Your query returns no records, or fails. To check failure do this:

$query = mysql_query ("Select * from confirm_members where email = '$name'") or die(mysql_error());

If it does not fail, check your data.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.