miftari0 miftari0 - 1 year ago 119
PHP Question

Searh engine using url

Hey i started making site for songs. It is lyrics site and i wanted a search engine that works something like picture below.

It should works with URL.

Like this

anybody help?

<form action="#" method="POST">
<input type="text" name="search"/>
<input type="submit" name="submit" value="Submit">
require "connection-to.php";
$notFound = "";
$song = "";
$search = mysqli_real_escape_string($conn, $_POST['search']);
$search = strtolower($search);
$sql = "SELECT * FROM `music` WHERE `name` = '" . $search . "'";
$query = mysqli_query($conn, $sql);
$numRows = mysqli_num_rows($query);
if($numRows != 0){
while($row = mysqli_fetch_array($query)){
echo $row['lyrics'] . "<br><br><br>";
} else {
echo $search . " Was Not Found.";

Answer Source

You don't want send a POST request. Change

<form action="#" method="POST">


<form action="" method="GET">

Then you can retrive it with $_GET['search'] instead of $_POST['search'].

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download