如何将html表单的输入转发到Drupal 7登录表单?

时间:2015-11-13 10:31:25

标签: php drupal drupal-7

我在html中创建了一个表单,如下所示:

<form class="login active">
    <h3>Login</h3>
    <div>
        <label>Username:</label>
        <input type="text" name="username"/>
    </div>
    <div>
        <label>Password: </label>
        <input type="password" name="password"/>
        <label><a href="forgot_password.html" rel="forgot_password" class="forgot linkform">Forgot your password?</a></label>
    </div>
    <div class="bottom">
        <div class="remember"><!--<input type="checkbox" />--><span><!--Keep me logged in--></span></div>
        <input type="submit" value="Login"></input>
        <a href="register.html" rel="register" class="linkform">You don't have an account yet? Register here</a>
        <div class="clear"></div>
    </div>
</form>

我需要做的是让用户使用我的html表单登录Drupal。提前致谢

2 个答案:

答案 0 :(得分:0)

在template.php中写道:

<?php
function mytheme_theme(&$existing, $type, $theme, $path) {
      $hooks['user_login'] = array(
      'template' => 'templates/user_login',
      'render element' => 'form',
      // other theme registration code...
    );

    return $hooks;
}

function mytheme_preprocess_user_login(&$variables) {
    $variables['intro_text'] = t('This is my awesome login form');
    $variables['rendered'] = drupal_render_children($variables['form']);
}
?>

然后,您可以在目录user_login.tpl.php中创建templates

更多信息:Customizing the login formfunction hook_theme

答案 1 :(得分:0)

使用hook_menu注册自定义模块的自定义路径可以解决您的问题:https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7

之后,只需使用user_authenticate等功能对用户进行身份验证:https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_authenticate/7

这两个链接都为您提供了示例。