I am looking for a script which will allow me to place a vbulletin login box on a non vbulletin page. There are couple of scripts, but they are for older versions. I am using v3.6.8
Does anyone know where to find one for 3.6.8?

The closest I could find was this:

(offcourse I will ask them permission before using it as I'm not using it on one of their templates)

I tested it and it worked, but I have a problem.

When I'm logged out of my forum I go to the page that I inserted the script in, I then log in, and it redirects me to the forum page, logs me in and redirects me back, just how it should.
I am logged into the forum then, but it doesn't show on the page that I'm logged in, it still shows the login form. So, all we need to do is to tell the script that when the user is logged in, it must replace the login box with this:

Welcome, Deidre.
You last visited: Today at 07:03 PM
Private Messages: Unread 0, Total 0.

My programing knowlege is not very good.... Anyone who will give me a tip or two here?

Dani AI

Generated

What you are seeing (logs in, redirects back, but the external page still shows the form) usually means the external page is not bootstrapping vBulletin to read the logged-in session, or the cookies are not scoped so that the non-vB page can see them. is right that the form alone is static; you need to initialize vBulletin on that page and read $vbulletin->userinfo. shows the right idea by requiring global.php. Two other common culprits: incorrect cookie scope and caching.

Quick checklist that fixes most cases:

  • In AdminCP > vBulletin Options > Cookie and HTTP Header Options: set Cookie Path to / and, if the forum and the external page share the same parent domain, set Cookie Domain to .example.com. Save, then clear your browser cookies and test again.
  • On the external PHP page, bootstrap vBulletin with an absolute path, then read the session hash and user info.
<?php
define('THIS_SCRIPT','ext_login');
chdir($_SERVER['DOCUMENT_ROOT'] . '/forums');
require_once('./global.php');
chdir(dirname(__FILE__));
$sessionhash = $vbulletin->session->vars['sessionhash'];
?>
  • Use the session hash and a safe return URL in your form so login returns to the same page:
<input type="hidden" name="s" value="<?php echo $sessionhash; ?>">
<input type="hidden" name="url" value="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); ?>">
  • Make sure the MD5 script path is correct from the external page (e.g., /forums/clientscript/vbulletin_md5.js).
  • Prevent stale output: if a CDN or proxy is in front, or the page was previously static, send no-cache headers and ensure the file is .php.

Once global.php is loaded, you can replace the form with a welcome block using $vbulletin->userinfo['username'], lastvisit, and pmunread. That mirrors what suggested about using the url field, but populates it dynamically and makes the external page truly session-aware.

Recommended Answers

All 5 Replies

Having the login form is no problem.

<!-- login form -->
		<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">

		<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=370b5h"></script>
		<table cellpadding="0" cellspacing="3" border="0">
		<tr>
			<td class="smallfont"><label for="navbar_username">User Name</label></td>
			<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /></td>
			<td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />Remember Me?</label></td>
		</tr>

		<tr>
			<td class="smallfont"><label for="navbar_password">Password</label></td>
			<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td>
			<td><input type="submit" class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" /></td>
		</tr>
		</table>
		<input type="hidden" name="s" value="" />
		<input type="hidden" name="do" value="login" />		
		<input type="hidden" name="vb_login_md5password" />

		<input type="hidden" name="vb_login_md5password_utf" />
		</form>
		<!-- / login form -->

However, when you start talking about it knowing when you're logged in, and displaying your user information, now you're talking about a dynamic page that pulls information from the database. Since you self-acknowledged you're not a PHP programmer, I would check out vBulletin.org and, more specifically, the vBAdvanced CMPS product. It might be just what you're looking for.

<?php
$curdir = getcwd();
chdir('YOURROOTTOFORUMS');
require_once('YOURROOTTOFORUMS/forums/global.php');
chdir($curdir);
if ($vbulletin->userinfo['userid'] == 0) {
  echo "<center><form id=\"login\" action=\"/forums/login.php?do=login\" method=\"post\" onsubmit=\"md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)\">
<script type=\"text/javascript\" src=\"clientscript/vbulletin_md5.js?v=364\"></script>
<a href=\"/forums/register.php\">Register</a>
<label for=\"navbar_username\">Username</label>
<input type=\"text\" class=\"bginput\" style=\"font-size: 11px\" name=\"vb_login_username\" id=\"navbar_username\" size=\"10\" accesskey=\"u\" tabindex=\"101\" onfocus=\"if (this.value == 'User Name') this.value = '';\" />
<label for=\"navbar_password\">Password</label>
<input type=\"password\" class=\"bginput\" style=\"font-size: 11px\" name=\"vb_login_password\" id=\"navbar_password\" size=\"10\" tabindex=\"102\" />
<label for=\"cb_cookieuser_navbar\"><input type=\"checkbox\" name=\"cookieuser\" value=\"1\" tabindex=\"103\" id=\"cb_cookieuser_navbar\" accesskey=\"c\" />Remember Me?</label>
<input type=\"submit\" class=\"button\" value=\"Login\" tabindex=\"104\" title=\"Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself.\" accesskey=\"s\" />
<input type=\"hidden\" name=\"s\" value=\"\" />
<input type=\"hidden\" name=\"do\" value=\"login\" />        
<input type=\"hidden\" name=\"vb_login_md5password\" />
<input type=\"hidden\" name=\"vb_login_md5password_utf\" />
</form>";
} else {
  echo "<center>Welcome Back, <b>".$vbulletin->userinfo['username']."</b>";
  if ($vbulletin->userinfo['usergroupid'] == '6' ) {
  echo "&nbsp;|&nbsp;<a href=\"/forums/member.php?1-".$vbulletin->userinfo['username']."\">My Profile</a>";
  echo "&nbsp;|&nbsp;<a href=\"/forums/egncadmincp/index.php\">AdminCP</a>";
  echo "&nbsp;|&nbsp;<a href=\"/forums/egncmodcp/index.php\">ModCP</a>";
  }
}
?>

Sorry the above code works 100% its a great way of logging people in you may need to edit the way the form looks in the echo however it works great.

Hello friends, sorry about post in a old post, but I'm using the code and it login BUT when I back to the page, isn't logged, someone can help me? Please? (Is a non vBpage is an external .php) (In the main directory, and my forum is in /forums)

Thanks in advance!!

    <input type="hidden" name="s" value="$session[sessionhash]" />
    <input type="hidden" name="do" value="login" />      
    <input type="hidden" name="vb_login_md5password" />
    <input type="hidden" name="vb_login_md5password_utf" />
    <input type="hidden" name="url" value="REDIRECTION URL HERE" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.