login form

Sajidsajid

New Member
hello guys i want to put the login form of vbulletin on my home page. I got the html login form of vbulletin.
HTML:
<form 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="forums/clientscript/vbulletin_md5.js?v=364"></script>
User Name: <input type="text" name="vb_login_username" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /><br />
Password: <input type="password" name="vb_login_password" tabindex="102" /><br />
<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" />
<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>

What i wanna do is make it say:
Welcome(username)
You last visited(time).
when the user is logged in but show the login form when not logged in.
I think it has something to do with cookies. but i can figure it out.
Please give a code to make the form.
 

Sajidsajid

New Member
*bump*
*double posting*
Hello Can someone pls help me?
This is very important...
I can't release my website for this....
Really urgent!!!

PLS Help
 

Sajidsajid

New Member
I have that code already but i need the php code. Like so that it will say:
welcome ($username)
You last visited($time)

Isn't that possible?
I have seen a lot of those type of login...
 

Sajidsajid

New Member
I AM USING THIS CODE. THIS IS VERY LONG:
Code:
<?php
$curdir = getcwd ();
chdir('/path/to/your/forums');
require_once('/path/to/your/forums/global.php');
chdir ($curdir);
?>
<html>
<head><title>Title</title></head>
<body>
SOME MESSAGE AND THE STYLE OF YOUR PAGE.



<?php
// Edit the lines below to show path to your forums
$forumpath = "community/";

// Avatar config start
$maxw = 100; // Max thumbnail width
$maxh = 100; // Max thumbnail height
//Avatar config end

// check if user logged in
if ($vbulletin->userinfo['userid']!=0) {


// ++++++++++++++++++++++++++++++++++
// display avatar - resize if too big
// ++++++++++++++++++++++++++++++++++

$userid=$vbulletin->userinfo['userid'];
$file = $forumpath."image.php?u=$userid";
list($width, $height, $type) = getimagesize($file);

if ( $width <= $maxw AND $height <= $maxh )// check width and height
   {// if width and height under size display unchanged
       echo "<img src=\"$file\" align=\"center\" border=\"0\">";
   }
   else 
   {  
	if ($width > $maxw)//check if width is too wide
		{ // if it is, resize
		$ratio = $width / $maxw; //work out resize ratio
		$newwidth = $maxw; // new width
		$newheight = ($height / $ratio); // new height at this resize
		}
		else
		{
		$newheight = $height; // if width is ok, set this cos we need it later
		$newwidth = $width; // if width was ok, set this cos we ned it later
		}
	If ($newheight <= $maxh )		
		{
		// if current height is ok, were done.
		} 
		
		else // either origional or resized height is too big
			if( $newheight >= $maxh )
			{ // if resized height is still too big we resize it
			$ratio2 = $newheight / $maxh; //work out resize ratio
			$newheight = $maxh; // give $newheight a new value
			$newwidth = ($newwidth / $ratio2); // new width at this resize
			} // the value of $newwidth has just been changed
			else
			{// if were here then origional height is too big so we resize it
			$ratio2 = $newheight / $maxh; //work out resize ratio
			$newheight = $maxh; // give $newheight a new value
			$newwidth = ($newwidth / $ratio2); // new width at this resize
			}

		// now we can finally display resized pic
        echo "<img src=\"$file\" border=\"0\" width = \"$newwidth\" height = 

\"$newheight\" align=\"center\">"; // display resized pic
   }
// +++++++++++++++++++++++  
// end avatar display code
// +++++++++++++++++++++++ 


// +++++++++++++++++++++++++++++++++++++++++
// If logged in display welcome message
// +++++++++++++++++++++++++++++++++++++++++
echo "Welcome Back, <b>";
echo $vbulletin->userinfo['username'];
echo " !</b><br />";

// As were logged in display logout link
echo "<a 

href=\"".$forumpath."login.php?$session[sessionurl]do=logout&logouthash=$logouthash";
echo $vbulletin->userinfo['logouthash'];
echo "\">";
echo "<font size=\"1\" face=\"verdana\">Log Out</font></a><br />";

// Display last visit time and date
echo "You last visited: $pmbox[lastvisitdate] at $pmbox[lastvisittime]";
echo "<br />";

// Display PM Details and generate link to PM box
echo "<a href=\"".$forumpath."private.php?$session[sessionurl] \">Private Messages: </a> 

$vbphrase[unread_x_nav_compiled] $vbphrase[total_x_nav_compiled]";
echo "<br />";

} else { 



// ++++++++++++++++++++++++++++++++++++++++++
// If not logged in show form:
// ++++++++++++++++++++++++++++++++++++++++++

// Display text and link to register.
echo "
	<a href=\"".$forumpath."register.php"><b>register</b></a>
	";

// Display login boxes + button
// You can style this with html or CSS as normal if desired.
echo"
	<form action=\"".$forumpath."login.php\" method=post 

onsubmit=md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)>
	<script type=text/javascript 

src=\"".$forumpath."/clientscript/vbulletin_md5.js\"></script>
	User Name:<br />
	<input name=vb_login_username type=text id=navbar_username onfocus=\"if 

(this.value == '$vbphrase[username]') this.value = '';\" size=10 />
			
	<br />Password:<br />
	<input name=vb_login_password type=password size=10 />
	</br>
		
	<label for=cb_cookieuser_navbar><input name=cookieuser type=checkbox 

id=cb_cookieuser_navbar value=1 checked=checked />
	Remember Me?<br /></label>
	
		
	<input type=submit title=$vbphrase[enter_username_to_login_or_register] 

value=\"Log In\" />
		
	<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 />

	</form>
";
// +++++++++++++++++++++++++++++++++++++++ 
// End of login box
// +++++++++++++++++++++++++++++++++++++++
}

// +++++++++++++++++++++++++++++++++++++++++++++++++++
// DISPLAY STATS
// +++++++++++++++++++++++++++++++++++++++++++++++++++

// get total number of threads and posts
$getstats = $db->query_read('SELECT threadcount, replycount FROM ' . TABLE_PREFIX . 

'forum');
while ($forum = $db->fetch_array($getstats))
{
	$totthreads += $forum['threadcount'];
	$totposts += $forum['replycount'];
}
$totthreads = vb_number_format($totthreads);
$totposts = vb_number_format($totposts);

// display total threads and total posts - Uses vB phrases, but change if you like
echo"<br /> $vbphrase[threads]: $totthreads<br />$vbphrase[posts]: $totposts<br /> ";

// Only display link and number of new posts if logged in
if ($vbulletin->userinfo['userid']!=0) {

// finds number of new posts
$newposts = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "post AS 

post " . iif($vbulletin->options['threadmarking'], 'LEFT JOIN ' . TABLE_PREFIX . 

'threadread AS threadread ON (threadread.threadid = post.threadid AND threadread.userid = 

' . $vbulletin->userinfo['userid'] . ')') . " WHERE dateline >= " . 

$vbulletin->userinfo['lastvisit'] . iif($vbulletin->options['threadmarking'], ' AND 

dateline > IF(threadread.readtime IS NULL, ' . (TIMENOW - 

($vbulletin->options['markinglimit'] * 86400)) . ', threadread.readtime)'));
$newposts = vb_number_format($newposts['count']);

echo"<a 

href=\"".$forumpath."search.php?$session[sessionurl]do=getnew\">$vbphrase[new_posts]</a>: 

$newposts<br />";}
//  end of stats
?>
</body>
</html>
 

salmandia

New Member
Sajidsajid said:
Anyone has any smaller and better code?

psilocybin said:
See if this hack will work for you:

Simple login page/box/code for external pages - vBulletin.org Forum

I attached the mod in case you wanted it.

i faced a problem with it

after logging in the code return me to another addres end with /path

for example

www.dm3ty.net/path

this addrese appears after logging in

note i change the path in the page as ãäÊÏíÇÊ ÏãÚÊí
 
Top