Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Search the user authentication database or other databases

Code Wizard, 12-30-2006



Script Note:
This code is designed to be used with the user authentication script that I added. It will search the user database for a specified username and their real name. If you want, you can configure it to search other databases. If you need help with anything, mail me at tyler.longren@midiowa.net or tyler@evilwalrus.com.

To the code!

Call this file search.php
<!---Begin serach.php--->
<html>
<head><title>Search</title></head>
<body bgcolor="#ffffff">
<form action="results.php" method="post">
<table border="0">
<tr>
<td><strong>Username</strong></td>
<td><input type="text" name="username" size="10" maxsize="50"></td>
</tr>
<tr>
<td><strong>Real Name</strong></td>
<td><input type="text" name="real_name" size="10" maxsize="50"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Go!"> <input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
</body>
</html>
<!---End search.php--->


Call this file results.php
<!---Begin results.php--->
<?
$connection = mysql_connect("localhost","root","F0AA2pa8")
or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("secretDB", $connection) or die ("Unable to select
database.");
$sql = "SELECT username, real_name
FROM users
WHERE username = '$username' AND real_name = '$real_name'";
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute SQL
query");
if ($row = mysql_fetch_array($sql_result)) { $id = $row["id"];
$username = $row["username"];
$real_name = $row["real_name"];
echo "$real_name ($username) was found!"; }
else {
echo "$real_name ($username) not found in the database!";
}
mysql_free_result($sql_result);
mysql_close($connection);
?>
<!---End results.php--->

If you find any problems with this script, please let me know.

Enjoy.
:)
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions