I have a simple search form and a mysql database includes only 1 table and 1 column. This will be my search.html Nothing but a search form only.
<form action="search.php" method="post">
<center> SEARCH:<input type="text" name="search" placeholder="SEARCH"><br></center>
<center> <input type="submit" class="btn-success btn"></center>
</form>
My database is so simple and has only 1 input. My table name is "kodlar" and my only column name is "kodveritabani"
This is my search.php so far. The results can even popup on a browser window. When hit search, lookup the database, if finds the same string echo "This is a valid code" if cannot find echo "This is not a valid code"
<?php
$link = mysqli_connect("localhost", "dbinfo", "dbinfo", "dbinfo");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$kodveritabani = mysqli_real_escape_string($link, $_REQUEST['kodveritabani']);
if(isset($_POST['search'])) {
$result = mysqli_query($con,"SELECT * FROM kodlar WHERE kodveritabani='".mysqli_real_escape_string($con,$_POST['search'])."'");
If(mysqli_num_rows($result)!=0) {
$row = mysqli_fetch_array($result);
echo "This is a valid code.";
}
Else {
echo "This is not a valid code.";
}
}
// Close connection
mysqli_close($link);
?>
What should I do to achieve my purpose?