单击表单提交按钮时重定向 [英] Redirect when form submit button is clicked

查看:97
本文介绍了单击表单提交按钮时重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码,它可以使用户成功登录,但我也需要这样做,以便一旦登录,他便被重定向到另一页,我对php不太熟悉,我在这里和google以及提交时进行重定向,我看到您更改了action ="destination url",但它已经包含了该php代码,如果我更改,它将无法正常工作. 感谢您提供的所有帮助.

I have this code it works the user logs in successfully but I also need to make it so that once logged in he gets redirected to another page I am not very familiar with php and I have looked around here and with google and to make redirect when submit I saw that you change the action="destination url" but it already has that php code in it and if I change that it does not work. I appreciate any and all help with this.

<div id="apDiv4">
<form name="login-form" id="sidebar-login-form" class="standard-form" action=" <?php echo site_url( 'wp-login.php', 'login_post' ) ?>" method="post">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
       <tr>
          <td>
        <label><?php _e( 'Username', 'buddypress' ) ?>
        <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" /></label>

           </td>
          <td>
        <label><?php _e( 'Password', 'buddypress' ) ?>
        <input type="password" name="pwd" id="sidebar-user-pass" class="input" value="" /></label>

           </td>           
        </tr>
        <tr><td>
        <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="sidebar-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ) ?></label></p></td>
                <td>
                <?php do_action( 'bp_sidebar_login_form' ) ?>
                <input type="image" value=<img src="http://anime.edgardoroldanonline.com/wp-content/themes/buddyboss-child-fixed-navbar/images/button-letmein.png" width="127" height="26" name="wp-submit" id="sidebar-wp-submit" tabindex="100" />
                <input type="hidden" name="testcookie" value="1" />

?>

                 </td>
</td>       
        </tr>
      </table></td>
    </tr>
  </table>
            </form>
</div>

推荐答案

由于其 wordpress ,与您一起工作时应在表单(redirect_to)中使用隐藏字段.这是一个功能.

As its wordpress your working with you should use a hidden field in your form (redirect_to). Its a feature.

<form name="login-form" id="sidebar-login-form" class="stand...
  <input type="hidden" name="redirect_to" value="http://redirect.to.com">

wp-login.php的第570行,它将在登录后处理重定向值:

on line 570 of wp-login.php it will handle the redirect value after login:

$redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);


旁注:您还可以直接使用 wp_redirect():


Side note: You can also directly invoke the redirect function with wp_redirect():

<?php
wp_redirect( $location, $status );
exit;
?>

这篇关于单击表单提交按钮时重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆