Hmm ok, i've searched this forum for a user login kinda php script. But my attempts to were to no avail. Im not super great in php. But how would i make a simple login on a non-vB page that would check to see if their logged in and keep them logged in globally?
Simple User Login
Collapse
X
-
Tags: None
-
Originally posted by AsterikHmm ok, i've searched this forum for a user login kinda php script. But my attempts to were to no avail. Im not super great in php. But how would i make a simple login on a non-vB page that would check to see if their logged in and keep them logged in globally? -
lol yes :P i'd use the same tables n stuff as vB3 and all that stuffComment
-
Originally posted by Asteriklol yes :P i'd use the same tables n stuff as vB3 and all that stuff
Code:[size=2]chdir([/size][size=2][color=#0000f0]'./yourforumdirectory (relative to the non-vB page)/'[/color][/size][size=2]);[/size] [size=2][b]require[/b]([/size][size=2][color=#0000f0]'global.php'[/color][/size][size=2]);[/size]
Displaying $bbuserinfo["userid"] on a non-vB page, for instance, will display the logged-in user's member id number. If the user is a guest, it will default to "0". Other $bbuserinfo examples include: $bbuserinfo["username"] to display the user's username, and $bbuserinfo["email"] to display their e-mail address. This will work for every field within the 'user' table of your vBulletin database by substituting any field name (userid, usergroupid, etc.) in place of "fieldname" in $bbuserinfo["fieldname"].
If you would like to write a simple PHP script to detect a login, try a simple conditional like:
Code:[size=2]if ($bbuserinfo["userid"]!=0)[/size] [size=2]{[/size] // If the user's userid is not 0, and therefore, is not a guest [size=2]echo ("You are logged in, ".$bbuserinfo["username"]."");[/size] [size=2]}[/size] [size=2]else[/size] [size=2]{[/size] [size=2]// If the user is a guest[/size] echo ("You are not logged in. Please login or register"); [size=2]}[/size]
Last edited by inthezone; Tue 4 Nov '03, 3:58pm.Comment
-
ok, i looked at the login.php file and used some code from that and it works! but how would i hide the form once they're signed in? and show the stats there or somethin?Last edited by Asterik; Tue 4 Nov '03, 5:20pm.Comment
-
lol read post again, i edited like right when u were respondinComment
-
Originally posted by Asterikok, i looked at the login.php file and used some code from that and it works! but how would i hide the form once they're signed in? and show the stats there or somethin?
Code:if ($bbuserinfo["userid"]!=0) { // The user's ID # is not equal to 0, and therefore, they are not a guest echo (" Welcome back, ".$bbuserinfo["username"].".<br /> You have made ".$bbuserinfo["posts"]." post(s). "); } else { // The user must be a guest, since their ID # is 0 <Insert HTML code for login form here. Remember to format the tags so that they are compliant with PHP, e.g. add a slash before quotation marks and apostrophes in HTML tags, so that type="text" will be type=\"text\"> }
Comment
-
Do you know how to make this work on pages that have existing mysql connections?
If I apply the trick you mentioned above, the connection to the forums database "takes over" and all the other php/mysql code the page is using stops working.
Is there any way I could "Strip out" some php code from vB to "just" check for the session/login information?
I'm using vB 2.2.3 (I know, it's old, but hey I hacked it enough to be scared to upgrade )
Thanks in advance
-manoComment
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Comment