This is one of those rare cases where I feel like I've tried everything! Help would be much appreciated...

I have created a custom theme. I'm using front.tpl.php to have a completely different layout for my home page. On it I would like to place a custom login box, which toggles to a My Account / Logout link when the user is already logged in. All other login boxes are working fine -- it's just the one on the home page that's giving me grief. It simply (re)loads the page without logging the user in.

I am (well, was, as I have it disabled now to try and get this working) using LoginToboggin. I tried the snippet on this page with no luck. I'm using clean URLs, so I updated the form action to match. No luck. I grabbed various form/field properties from viewing source on other login pages. Still no luck. I checked out the user.module file to see where Drupal gets its form settings from and saw this:

$form['#action'] = url($_GET['q'], drupal_get_destination());

If I'm reading that right, it seems that Drupal gets the form's action from the hidden page destination field itself. *scratches head*

Anyway, that's a whole lot of rambling about what I've done, but I have no idea what else to try. How does one create a login box from scratch??

Anyone who would like to take a look is welcome to contact me for the URL.

Thank you!

Comments

ojkelly’s picture

im doin the same thing

after searching this thread looks promising

http://drupal.org/node/58405

------------
http://ojk007.com

stephthegeek’s picture

This code ended up working for me:

<?php print l("Register","user/register"); ?> | Log in: <form action="<?php print url($_GET['q'], 'destination='); ?>" id="user-login-form" method="post"><input type="text" maxlength="64" class="form-text" name="edit[name]" id="edit-name" style="width: 94px" value="" />
<input type="password" class="form-password" maxlength="64" name="edit[pass]" id="edit-pass" style="width: 94px" value=""/>
<input type="hidden" name="edit[form_id]" id="edit-form_id" value="user_login_block"  />
<input type="submit" id="home-login-button" name="op" value="Log in" /></form>
ojkelly’s picture

Awesome, works for me too

also try

<?php  global $user; ?>
<?php if ($user->uid) : ?>
  Logged in as: <?php print l($user->name,'user/'.$user->uid); ?> |
<?php print l("logout","logout"); ?>
  <?php else : ?>
  <?php print l("Register","user/register"); ?> | Login: <form
action="user/login" method="post"><input type="hidden"
name="edit[destination]" value="user" /><input type="text"
maxlength="64" class="form-text" name="edit[name]" id="edit-name"
size="15" value="" /><input type="password" class="form-password"
maxlength="64" name="edit[pass]" id="edit-pass" size="15" value=""
/><input type="submit"  name="op" value="Log in"  /></form>
  <?php endif; ?>

http://ojk007.com

psi36’s picture

I've tried:
<form action="<?php print url($_GET['q'], drupal_get_destination())?>" method="post" id="user-login-form">
and nothing happens when I try to log in. I just end up on the start page again, but not logged in.

I've tried:
<form action="user/login" method="post">
but then I end up going to the standard login screen and have to fill in user name and password again.

I'm using Drupal 5.5

Any ideas?

psi36’s picture

I had<input name="form_id" id="edit-user-login-block" value="user_login_block" type="hidden" />
in stead of <input name="form_id" id="edit-user-login-block" value="user_login" type="hidden" />
I had to change value to "user_login" in the hidden field, now it works!

If you want the login block to appear on any page and stay on that page when you log in, use
<form id="user-login-form" method="post" action="user/login<?php print url($_GET['destination'], drupal_get_destination())?>">

That worked for me anyway.

freatida’s picture

Thanks psi36

thall’s picture

Could someone tell me how to modify this script when not using clean urls?

Thanks

sujayjaju’s picture

<?php  global $user; ?>
<?php if ($user->uid) : ?>
  Logged in as: <?php print l($user->name,'user/'.$user->uid); ?> |
<?php print l("logout","logout"); ?>
  <?php else : ?>
  <form action="/drupal/?q=user&amp;<?php print drupal_get_destination() ?>" method="post" id="user-login-form">
  <label for="edit-name">
    Username:
    <span class="form-required" title="This field is required.">*</span>
  </label>
  <input type="text" maxlength="30" name="name" id="edit-name"  size="15" value="" tabindex="1" />

  <label for="edit-pass">
    Password:
    <span class="form-required" title="This field is required.">*</span>
  </label>
  <input type="password" name="pass" id="edit-pass"  size="15"  tabindex="2" />

  <input type="hidden" name="form_id" id="edit-user-login" value="user_login"  />
  <input type="submit" name="op" id="edit-submit" value="Log in"  tabindex="3" class="form-submit" />
  </form>
<?php endif; ?>
SocialNicheGuru’s picture

I want to integrate my "Join box" with the functionality of logintoboggin or user login.

It has been a little difficult so thank you for this.

Chris

http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.

eff_shaped’s picture

bookmarking

Anonymous’s picture

subscribing