<?include "conninfo.php";

$s1=$_POST["search1"];

if($s1=="")//redirect back if blank
{
header("location:onebigsearch.php?err=1");
}

else if(strlen($s1)<3)//redirect back if short
{
header("location:onebigsearch.php?err=2");
}

else
{

	$query="SELECT * FROM people WHERE firstname like '$s1%' OR surname like '$s1%' OR favfood like '$s1%' OR starsign like '$s1%'";

	$result=mysqli_query($link,$query) or die("No");//actually runs query

	$numrows=mysqli_num_rows($result);
	
	if($numrows==0)
	{
	echo "Sorry nothing found";
		
	}
	else{
		echo "<h1>Results</h1>";
		while($r=mysqli_fetch_array($result))
		{
		//echo $r["id"];
		echo $r["firstname"]." ";
		echo $r["surname"]." ";
		echo $r["favfood"]." ";
		echo $r["starsign"]."<br>";
		}//end while
	}//end else (numrows)
	
}//end else

?>
