PHP Search error help please, 10 points if you can solve! :)?

Kieran

New member
Im using a tutorial on YouTube about how to make a search bar. right, so i have my index.php page and my search.php page, but when i click the "search" button, i get the last few characters come up from the search.php page, it comes up with this "; } } ?> when it should come up with either not enough characters, or you searched for $search. So how do i fix this? Thank you

CODE
___
Index.php
___________________________
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Games Place - Home</title>
<link href="css/gaming.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="top_nav">
<div id="search">Search:

<form action='search.php' method='GET'>
<input type='text' name='search'/>
<input type='submit' name='submit' value='Search' />
</form>

</div>
</div>
</div>
</body>
</html>
______________________________________…
search.php
__________________________
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];

if (!$button)
echo "You didnt search for a keyword.";
else
{
if (strlen($search)<=3)
echo "Search term too short.";
else
{
echo "You searched for $search<hr size='1'>";
}
}
?>



Thank you very much! :)
@Tdz didnt work :(
 
Back
Top