Tuesday, February 21, 2006

CPANEL and database

When you have usr and pw to the control panel it allows you to create the database
Here are the steps:
1. Login cpanel www.xxx.com/cpanel enter usr and pw
2. Click MySQL Database
it will bring to the following form

Add the database by clicking the button "add db" if you name the database is "db" if you login as username: saigon then the database will have saigon_db (it adds username_db where db is the name of your database)
Similar to users if you enter username: admin then it will add saigon_admin
password will the password you type for example you type 123 and pw is 123

Last step you add users into the database by select the database name and users and then click the button named "Add users to db". There are 3 steps need to be done to create the database and the users and its connection. So when connected to the database the file name is called /connection/connect.php
$login_name = "saigon_admin"; // you just created above
$password = "123"; // pw you created above
$dbname ="saigon_db"; // database you created above
$link = mysql_connect("$host","$login_name","$password"); mysql_select_db($dbname,$link) or die(mysql_error());?>

This connect.php file allows to connect to the database of mysql.

After you create the database you can review it by click "phpMyAdmin" at the bottom of the current page of MySQL Database. In here you can add member or remove member for admin your site.

There are 3 ways to add member to your site

1. From website you need to register username and pw in the form and click submit this is normal procedures for everyone, this will allowing member with lowest priority to post

You can increase the priority of this member by change the Rank in the member table (the priority: 1 lowest and priority: 3 highest)
2. You can add the member direct from table using phpMyAdmin make sure select encrypt for the password. Here is the enscript code of your pwd before it is stored in the database so no one know what it is, and it looks like something $1$rB1/MDpZ$jCXrblB2p0W38rQrrvylH. if you check the password field when it has been encrypted.

$Pass = crypt(trim($_POST["password"]));

3. You run this piece of code then enter into the password field without no enscript because when it echo into the screen you can cut the string and paste into the password field.

This is how 123 after encripted will look like
123
$1$Bt1.0o0.$LDUHS///PwOuRVMGJZjYn. (you can add this string into the pwd field and remember to select function field is BLANK instead of enscript because this string has been enscrip the following code.

The code to do this


# You should pass the entire results of crypt() as the salt for comparing a# password, to avoid problems when different hashing algorithms are used. (As# it says above, standard DES-based password hashing uses a 2-character salt,# but MD5-based hashing uses 12.)
$password = "123";
echo "$password";
echo "
";
$password1 = crypt("123");
$echo "$password1";

?>




No comments: