MySQL interesse |
|
Ik heb gezocht, is dit een goede manier?
// Collect the posted search query
$q = strtolower(mysql_real_escape_string($_POST['q']));
// Clean up by removing unwanted characters
$qclean = ereg_replace("[^ 0-9a-zA-Z]", " ", $q);
// Remove multiple adjacent spaces
while (strstr($qclean, " ")) {
$qclean = str_replace(" ", " ", $qclean);
}
// Replace single spaces with a URL friendly plus sign
$qclean = str_replace(" ", "+", $qclean);
// If validation has passed, redirect to the URL rewritten search page
if ($q != '') {
header( 'Location: http://www.bla.nl/'.$q );
}
// HTML is output after here – NOT BEFORE!
?>
<html>
<form method="post" action="">
<fieldset>
<input type="text" name="q" />
<input type="submit" value="Search" />
</fieldset>
</form>
</html>
// Collect the posted search query // Clean up by removing unwanted characters // Remove multiple adjacent spaces while (strstr($qclean, " ")) { } // Replace single spaces with a URL friendly plus sign // If validation has passed, redirect to the URL rewritten search page if ($q != '') { header( 'Location: http://www.bla.nl/'.$q ); } // HTML is output after here – NOT BEFORE! ?> <html> <form method="post" action=""> <fieldset> <input type="text" name="q" /> <input type="submit" value="Search" /> </fieldset> </form> </html>
|