PDA

View Full Version : Grab Username and Password on Non-VB Page


09-17-2000, 03:25 PM
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?

09-18-2000, 11:40 AM
Bump. :)

09-18-2000, 01:14 PM
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

09-18-2000, 01:18 PM
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. :)

09-18-2000, 01:27 PM
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

09-18-2000, 01:38 PM
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! :)

09-18-2000, 01:48 PM
Got it to work! Thanks! :)

09-18-2000, 01:55 PM
Could you let me know how you got it to work? Thanks in advance.

09-18-2000, 02:04 PM
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.

09-18-2000, 06:59 PM
Thanks...