hi all
i have below php code which check the user name from a CSV file...
I want to check from sql database... i m not getting any clue how to do it.. plz help
PHP Code:
<?
$username = $_POST['username']; // get the username
$username = trim(htmlentities($username)); // strip some crap out of it
$file = '/folder/data.csv'; // Here's the file. Notice the full path.
echo check_username($file,$username); // call the check_username function and echo the results.
function check_username($file_in,$username){
$username=strtolower($username);
$file = file($file_in);
foreach ($file as $line_num => $line) {
$line = explode(',',$line);
$user = trim(str_replace('"','',$line[0]));
if($username == strtolower($user)){
return '<span style="color:#f00">Username Unavailable</span>';
}
}
return '<span style="color:#0c0">Username Available</span>';
}
?>
Bookmarks