View Full Version : login .php needed

01-22-2003, 05:40 AM
I am making a site, and I want to add a "members area" to it. Now, how would i do the following:

1- Have a .php file to determine if the password and user name are valid and confirmed by me
2- have various sub sites that can only be accessed through the page where you enter your password.

thanks a lot to anyone who can help me

01-22-2003, 06:37 AM


01-22-2003, 07:41 PM
thank you, that helps me a lot.

01-22-2003, 09:36 PM
ok, im having a problem with the one for the first link you gave me. for some reason, someoen trys to register, but it just says "database unavailable". i double checked and changed the right info, but it still wont work. any suggestions?

01-22-2003, 11:27 PM
One suggestion: Post the non-working part of your code so we can have a look at it. Improves efficiency of helping you, in your interest.

01-23-2003, 01:32 AM
thats another problem, its not my script, i downloaded it, and for some reason it wont connect to the database when you try to register.


can it be somewhere in this?

<?php // db.php

$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";

function dbConnect($db="") {
global $dbhost, $dbuser, $dbpass;

$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die("The site database appears to be down.");

if ($db!="" and !@mysql_select_db($db))
die("The site database is unavailable.");

return $dbcnx;

i am not that good with php, so thats the best i can do(i changed it so it doesnt show my database info.)

01-23-2003, 11:36 AM
Remove the '@' before the function calls. They are used to suppress error messages, but in your case, you rather want to see a message what's wrong with that code. It looks ok to me - is your database down? The error messages might give you a hint.

01-23-2003, 07:19 PM
no, the database is not down.

01-23-2003, 07:27 PM
And the error message?

01-23-2003, 08:01 PM
what about it? i dont know why it keeps saying it. that is why i am asking for help.

01-23-2003, 11:09 PM
My bad, removing the error suppressing operator seems not to be sufficient. Try this modified function instead

function dbConnect($db="") {
global $dbhost, $dbuser, $dbpass;

$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) or die("The site database appears to be down.");

if (!mysql_select_db($db)) {
echo mysql_error();

return $dbcnx;

...and that should print a more descriptive reason why the selection of the database failed, like 'Unknown database (value of $db)'.

01-23-2003, 11:14 PM
thanks for the help. i actually found a better connection script, ill give ya a link when im finished editing it.