View Full Version : Grab Username and Password on Non-VB Page
Hi,
I've got a little user-comment system where people registered with my copy of vBulletin can post little SlashDot-style comments after a news story...it works fine and all, but I was wondernig if I could check to see if they were "logged in" with their cookie info and, if so, have their username and password already in the fields? I just need the command to grab the cookie info really - is it possible?
Just do something like this:
Assuming your current html page is "usercomments.html"
Make a new template called "usercomments" and dump all of "usercomments.html" into it.
The make a file called "usercomments.php" with the following code:
<?
require("global.php");
if ($bbuserid == 0)
{
eval("echo standarderror(\$bbtitle,\"".gettemplate("error_nopermission")."\");");
exit;
}
if ($bbusername == "" || (isset($bbusername))==0)
{
$getusername=$DB_site->query_first("SELECT username FROM user WHERE userid=$bbuserid");
$username=$getusername[username];
$bbusername = $username;
}
else
{
$username = $bbusername;
}
eval( "echo dovars(\"" . gettemplate( "usercomments" ) . "\");" );
?>
Now when the user accesses the page, if they are logged in they see the contents of the "usercomments" template. If they arent logged in they are prompted to enter a username and password
HTH
~Chris
Unfortunatly that won't work...what I have is news articles that I want ANYONE to be able to view...not just people logged in. So something like this would restrict it so that only registered members could view them...
Isn't there a way to simply grab the username and password? If I can get those into some variables, I can easily have them populate the two form fields. :)
If you want everyone to be able to see them, I dont see the point of having a login form.
Either way the values are already available by calling $bbpassword and $bbuserid. To get the username you will have to query the usertable against the value of $bbuserid
HTH
~Chris
I don't think you follow. :):
I have movie news on this site...stories on casting, new movies being made, release dates, etc. I want this to be public to all of course...not a good idea to make people register just to view the news...
Anyway, at the END of every movie news article, there is a little form where you can leave your comments/thoughts on the article with your username and password if you're registered with our copy of vBulletin...
Hope that clears things up - thanks for the help...I'll give it a try! :)
Got it to work! Thanks! :)
Could you let me know how you got it to work? Thanks in advance.
if (isset($bbuserid))
{ do stuff }
Instead of "do stuff" you'll want to use a MySQL query to grab the username and password from the table "user." based on the $bbuserid variable.
I then simply used something like this:
<b>Username: </b><input type="text" name="user" value="<?php echo("$theusername");?>"><br>
If the variable is empty, then it isn't filled in...if it is - then its filled in.
It's all part of this system I've got integrated with vBulletin - when it's all done and officially launched I'll post it here for all to see...it's quite cool.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.