English 中文(简体)
主页登录形式 - Wordpress
原标题:Homepage Login form - Wordpress

我在我的网站主页上安装了登录表, 但是, 当我去登录时, 它实际上不允许我登录。 在我选择“ LOGIN ” 之后, 我的 URL 结尾写道 : “? username=admin& password=admin& submit ” 。

<强> 这是 HTML:

<div id="navbar">
        <?php wp_nav_menu( array(  menu  =>  Primary Menu ,  container  => false, menu_id  =>  main-nav , depth => 2 )); ?>
            <div id="login" >
        <?php if (!(current_user_can( level_0 ))){ ?>               
        <form>
            <input type="text" name="username" id="username" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" style="padding-left: 2px;" onfocus="if(this.value==this.defaultValue) this.value=  ;" onblur="if(this.value==  ) this.value=this.defaultValue;" />
            <input type="password" name="password" id="password" style="padding-left: 2px;" onfocus="if(this.value==this.defaultValue) this.value=  ;" onblur="if(this.value==  ) this.value=this.defaultValue;" />
            <input type="submit" name="submit" value=" " class="loginbutton" />
                </form>
                <a class="helpbutton" href="<?php echo get_option( home ); ?>/wp-login.php?action=lostpassword"></a>
        <?php } else { ?>
        <ul class="admin_box">
                    <li><a href="<?php echo get_option( home ); ?>/wp-admin/">Dashboard</a></li>
                    <li><a href="<?php echo get_option( home ); ?>/wp-admin/post-new.php">Write new Post</a></li>
                    <li><a href="<?php echo get_option( home ); ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER[ REQUEST_URI ]) ?>">Log out</a></li>
            </ul>
        <?php }?>
            </div>
        </div>

这里是 CSS:

/* Login
-----------------------------------------------------------------------------*/
#login {
    background-image:url(images/bluenavbg.png);
    height:39px;
    width: 370px;
    float:right;
    margin-right: 0px;
    margin-top: 0px;
}

form {
    float: left;
    margin-top: 10px;
    margin-left: 20px;
}

input {
    background:url(images/formbg.png);
    width: 117px;
    height: 20px;
    margin-left: 5px;
    border:none;
    margin-left: 3px;
}

.loginbutton {
    height: 20px;
    width: 40px;
    margin-left: 5px;
    background:url(images/loginbutton.png);
}
.helpbutton {
    height: 20px;
    width: 38px;
    margin-right: 10px;
    background:url(images/helpbutton.png);
    margin-top: 10px;
    float: right;
}

#login ul {
    float: left;
    color: white;
    padding-left: 55px;
}

#login li a {
    float: left;
    color: white;
    text-align: center;
}

任何帮助都将不胜感激。

问题回答

我注意到你错过了 与你形式相关的动作属性

<form name="loginform" id="loginform" action="<?php echo get_option( siteurl ); ?>/wp-login.php" method="post">

        <input value="Username" class="input" type="text" size="20" tabindex="10" name="log" id="user_login" onfocus="if (this.value ==  Username ) {this.value =   ;}" onblur="if (this.value ==   ) {this.value =  Username ;}" /> <input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me? <br />
        <input value="Password" class="input" type="password" size="20" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value ==  Password ) {this.value =   ;}" onblur="if (this.value ==   ) {this.value =  Password ;}" />
        <input name="wp-submit" id="wp-submit" value="Log In" tabindex="100" type="submit">
        <input name="redirect_to" value="<?php echo get_option( siteurl ); ?>/wp-admin/" type="hidden">
        <input name="testcookie" value="1" type="hidden">

</form>

我把它加到你下面的代码里了

<div id="navbar">
        <?php wp_nav_menu( array(  menu  =>  Primary Menu ,  container  => false, menu_id  =>  main-nav , depth => 2 )); ?>
            <div id="login" >
        <?php if (!(current_user_can( level_0 ))){ ?>               
        <form name="loginform" id="loginform" action="<?php echo get_option( siteurl ); ?>/wp-login.php" method="post">

            <input value="Username" class="input" type="text" size="20" tabindex="10" name="log" id="user_login" onfocus="if (this.value ==  Username ) {this.value =   ;}" onblur="if (this.value ==   ) {this.value =  Username ;}" /> <input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me? <br />
            <input value="Password" class="input" type="password" size="20" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value ==  Password ) {this.value =   ;}" onblur="if (this.value ==   ) {this.value =  Password ;}" />
            <input name="wp-submit" id="wp-submit" value="Log In" tabindex="100" type="submit">
            <input name="redirect_to" value="<?php echo get_option( siteurl ); ?>/wp-admin/" type="hidden">
            <input name="testcookie" value="1" type="hidden">

    </form>
                <a class="helpbutton" href="<?php echo get_option( home ); ?>/wp-login.php?action=lostpassword"></a>
        <?php } else { ?>
        <ul class="admin_box">
                    <li><a href="<?php echo get_option( home ); ?>/wp-admin/">Dashboard</a></li>
                    <li><a href="<?php echo get_option( home ); ?>/wp-admin/post-new.php">Write new Post</a></li>
                    <li><a href="<?php echo get_option( home ); ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER[ REQUEST_URI ]) ?>">Log out</a></li>
            </ul>
        <?php }?>
            </div>
        </div>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签