Ok first off I have looked at this post and found some good answers.
Add VB login to custom pages
This however did not answer my question. Here is my layout
Main website
www.mywebsite.com
My forums are located here
www.mywebsite.com/forums
I want to be able to create pages in my main website directory that allows me to use the "USER" table to authenticate user on my site. If I use the example from the post above..
PHP Code:
chdir("./forumdir");
require("./global.php");
chdir("../");
if($bbuserinfo['userid'])
{
.........
exit;
}
else
{
print_no_permission();
}
It will work great if I have already logged into the forums. If not it takes me to a login screen for the forums which is fine but it places the base path as main website
www.mywebsite.com not
www.mywebsite.com/fourms. I have tried this with out luck.
PHP Code:
$db_name = "myDatabase";
$table_name = "user";
$link = mysql_connect("localhost", "username", "password") or die("Could not connect to server!");
$select_db = mysql_select_db($db_name, $link);
$query = "SELECT * FROM " . $table_name . " WHERE username = '" . $username . "' AND password = password('" . $password . "')";
$result = mysql_db_query($db_name, $query, $link) or die("Could not complete database query");
$num = mysql_num_rows($result);
if ($num != 0) {
$row = mysql_fetch_array($result);
$session = session_id();
setcookie("valid_userid", $row[userid], time()+ 31536000, "/", "", 0);
$_SESSION["myAuthorization"] = "YES";
$_SESSION["myUserID"] = $row['userid'];
$_SESSION["myUserName"] = stripslashes($row['username']);
$_SESSION["myUserTitle"] = stripslashes($row['usertitle']);
$_SESSION["myEmail"] = stripslashes($row['email']);
} else {
echo "Not a valid user";
}
I am looking for anyway to authenticate it does not have to be the above method I tried. Just allow me to use the "USER" table to authenticate and put info into sessions so I can allow certian people access to certian pages. Any ideas are welcome thanks.