Hi all,
I have a search button button using Post method. I have a search.php to display the data based on the search criteria. But I am stuck. no error message but could only display “Please enter a search query”
Here is the php code:
<?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){ $name=$_POST['name']; //connect to the database $con = mysql_connect("localhost","db_username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bgcomp_jo152", $con); $name = $_POST['name']; $result = mysql_query ("select * from Customer_Registration where Firstname like '%$name%' or lastname like '%$name%' "); $row = mysql_fetch_row($result); $Firstname = $row[7]; $lastname = $row[8]; $Address = $row[9]; $Postcode = $row[10]; ?> <form>
<table width="100%" border="2" cellspacing="0" cellpadding="8">
</form>
<?php
}
}
else{
echo “
Please enter a search query
”;}
}
?>