Jump to content

username check


jakebur01

Recommended Posts

Hello,

<?php
// your database connection
$username = "Ken"; // username you want to check
$sql = mysql_query("SELECT username FROM customer WHERE username='$username'");
$num = mysql_num_rows($sql);
if ($num > 0) {
   // do something => username exists
}
else {
  // do something else => username doesn't exist
}
?>

 

Ken

Link to comment
Share on other sites

if i put my connection on the page, is their a possibility that ppl can see it? if so, how?

 

why do most ppl use include files?

Hello,

Well it depends. If you show them the PHP file, then yes. You can't page source the connection data if that's what you mean. And people use include files for flexibility. Say you have a few PHP files that require database connections. Rather than writing it on every page, you just include the file. Also, it makes it easier for you to edit one file than multiple file if you either mistyped your username/password or whatever. Or maybe you changed your password. Then you would have to edit all the files, but with include, you just edit one file. ;)

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.