Hi there,
My code works fine and retrieves information from my database BUT when the search form is empty and I click submit all the information from my database appears.
How can I have it so when submit is clicked nothing happens or a message appears like "Nothing entered"
Thanks a lot!
James
My code works fine and retrieves information from my database BUT when the search form is empty and I click submit all the information from my database appears.
How can I have it so when submit is clicked nothing happens or a message appears like "Nothing entered"
Thanks a lot!
James
Code:
<html>
<body>
James' New Site
<form action="seaside.php" method="post">
<input type="text" name="search"><br>
<input type="submit">
</form>
<hr width="100%"></hr>
</body>
</html>
<?php
$search = "%" . $_POST["search"] . "%";
mysql_connect ("", "", "");
mysql_select_db ("");
$query = "SELECT name,msg FROM contact WHERE name LIKE '$search'";
$result = mysql_query ($query);
if ($result) {
while ($row = mysql_fetch_array ($result)) {
echo "<br>$row[0]</br>";
echo $row[1];
}
}
?>
Comment