Hey guys, I'm a new web developer doing things kinda out of my reach so if I sound stupid I'm sorry. I am trying to create a mysql database with usernames and passwords which php will connect to and verify, then in turn redirect the user accordingly. I found a script that does just that but I have some questions about it.
I created the Mysql database as such...
CREATE TABLE tbl_auth_user (
user_id VARCHAR(10) NOT NULL,
user_password CHAR(32) NOT NULL,
PRIMARY KEY (user_id)
);
INSERT INTO tbl_auth_user (user_id, user_password) VALUES ('theadmin', PASSWORD('chumbawamba'));
INSERT INTO tbl_auth_user (user_id, user_password) VALUES ('webmaster', PASSWORD('webmistress'));
//Now that that is created I looked at the PHP code and this is what I have questions on.
<?php
// we must never forget to start the session
session_start();
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
include 'library/config.php';
include 'library/opendb.php';
$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
// check if the user id and password combination exist in database
$sql = "SELECT user_id
FROM tbl_auth_user
WHERE user_id = '$userId'
AND user_password = PASSWORD('$password')";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_in'] = true;
// after login we move to the main page
header('Location: main.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
include 'library/closedb.php';
}
?>The part that confuses me is the library directory. Do I actually have to create a library directory and the files called closedb.php and opendb.php or is this some apache built in server feature. If i do need to create the directory... are these files already created? The reason I ask is because in the tutorial he gave no source to these files, so I am wondering if they are a standard web script that can be obtained someplace.
Thank you for any input you may have in advance,
Squeaker2