Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: brianjw - tammikuu 17, 2009, 03:30:45 IP

Otsikko: Login Box Troubles
Kirjoitti: brianjw - tammikuu 17, 2009, 03:30:45 IP
Hi Guys,

I am trying to put a login box on a php page outside of SMF. However, I am not wishing to do it with the ssi_login function.

I've got the code for the external page, here it is:

<?php
if ($context['user']['is_logged'])
        {
echo '<form>
<label>Hello, '
$context['user']['name'], '</label>
<font color="white" size="-1">Your current actions are limited on this website, '
$context['user']['name'], '</font>
<br class="spacer" />
</form>'
;
}
else
{
echo '
<form action="'
$scripturl'?action=login2" method="post" accept-charset="UTF-8" onsubmit="hashLoginPassword(this, \'625ca73a6555dbbe2979eabefe27518c\');">
<label>Members Login:</label>
<input type="text" name="user" id="username" />
<input type="password" name="passwrd" id="pass" />
<input type="image" src="images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
<br class="spacer" />
</form>'
;

?>


And SSI.php and the globals are of course included at the top of the page:

<?php
require("/home/**/public_html/**/community/SSI.php");
// The Login System
global $context;
global 
$scripturl;
?>



Ok. That entire code looks 100% correct to me. Here is my issue:

The form logs into SMF like it should and it directs to the homepage of the forum...
Otsikko: Re: Login Box Troubles
Kirjoitti: 10dc - tammikuu 17, 2009, 07:02:32 IP
Nice info and tips bro :) Thanks :)
Otsikko: Re: Login Box Troubles
Kirjoitti: brianjw - tammikuu 17, 2009, 08:53:59 IP
Lainaus käyttäjältä: udin_azza - tammikuu 17, 2009, 07:02:32 IP
Nice info and tips bro :) Thanks :)
Um... your welcome. But it was a support question lmao. ;)
Otsikko: Re: Login Box Troubles
Kirjoitti: brianjw - tammikuu 18, 2009, 05:24:20 IP
24 Hour Bump
Otsikko: Re: Login Box Troubles
Kirjoitti: Rumbaar - tammikuu 27, 2009, 06:50:27 IP
It looks like you are happy to edit files, why not edit that login function at the SSI.php level to incorporate your design requirements?
// Shows a login box.
function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;

if ($output_method != 'echo' || !$user_info['is_guest'])
return $user_info['is_guest'];

echo '
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">', $txt['username'], ':</label>&nbsp;</td>
<td><input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">', $txt['password'], ':</label>&nbsp;</td>
<td><input type="password" name="passwrd" id="passwrd" size="9" /></td>
</tr><tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="submit" value="', $txt['login'], '" /></td>
</tr>
</table>
</form>';
}