How can i make it so that when you type in text in a field and click submit, it searches the database for it and if its found it says "found" and if not it says "not found" The code im currently working with is: <? $sdb = $_POST["check"]; $query = "SELECT * FROM licensed WHERE domain = $sdb"; $result = mysql_query($query); if($_POST["check"]==""){ } else{ if($_POST["check"]==$result){ echo'<br><center>Found</center>'; } else { echo'<br><center><font color="red">'.$_POST["check"].' was not found</center>'; } } ?> Code (markup): oh, and i have the config.php and its included on the page i have the above code.: $db_host = "localhost"; $db_name = "########"; $db_user = "##########"; $db_pass = "#######"; $connection = @mysql_connect ($db_host,$db_user, $db_pass) or die ("Cannot make the connection"); //connect to database $db = @mysql_select_db ($db_name,$connection) or die ("Cannot connect to database"); Code (markup):
<?php $sdb = $_POST['check']; $query = "SELECT * FROM licensed WHERE domain = '$sdb'"; $result = mysql_query($query); $myrecord = mysql_fetch_array($result); if($myrecord['domain']!=''){ echo'<br><center>Found: '.$myrecord['domain'].'</center>'; } else { echo'<br><center><font color="red">'.$_POST['check'].' was not found</center>'; } ?> PHP: That should work. There are many ways to pull it off. Notice the single quotes in arrays. You need a loop if you expect more then one record returned from the query.
You're welcome. Did it get ya going in the right direction? Are you aware of www.php.net where you can find all the functions? CLick the underlined functions in the php code in my post for a description of that function too.