I'm working on a project that has two parts. 1.) A php form that uploads user entries into my database. This part is done.
2.) The same form, used to search the database and return the found results to the user.
What ive been able to do so far, is have the form re-print my data that i entered, but it does not matter if it is on my db or not. Here is the code, any help would be appreciated. (Note, im an absolute beginner and my job requires me to do things that i do not know how to do. That's why i'm here )
<?php
if (!empty($_POST['submit'])) {
$username="";
$password="";
$database="contacts";
$first=$_POST['first'];
$last=$_POST['last'];
$dept=$_POST['dept'];
$book=$_POST['book'];
$conf=$_POST['conf'];
$journal=$_POST['journal'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT first, last, dept, email, web, book, conf, journal FROM contacts WHERE first LIKE '%$first%' and last LIKE '%$last%' and dept LIKE '%$dept%' and email LIKE '%$email%' and web LIKE '%$web%' and book LIKE '%$book%' and conf LIKE '%$conf%' and journal LIKE '%$journal%')";
mysql_query($query);
mysql_close();
echo "<b>PLEASE ONLY HIT SUBMIT ONCE ON THIS FORM</b>";
}
?>
<html>
<body>
<form action="search.php" method="post">
First Name: <input type="text" name="first">
Last Name: <input type="text" name="last"><br>
Department: <input type="text" name="dept"><br>
E-mail-Add: <input type="text" name="email">
<align="right"> Website: <input type="text" name="web"></align><br>
<p>Book(s):<BR>
<TEXTAREA NAME="book" COLS=40 ROWS=6></TEXTAREA><br>
Conference(s):<BR>
<TEXTAREA NAME="conf" COLS=40 ROWS=6></TEXTAREA><br>
Journal(s):<BR>
<TEXTAREA NAME="journal" COLS=40 ROWS=6></TEXTAREA><br>
<input type="submit" name="submit" value="submit">
</form>
</body>