尝试在前端创建自定义注册页面,但在错误/成功情况下尝试重新加载页面时,会在chrome中显示该消息
“确认表单重新提交
您正在查找输入的已用信息的页面。返回该页面可能会导致重复您所做的任何操作。是否要继续?“”
我的代码:
the_post();//Iterate the post index in the loop.
get_header();
$err = \'\';
$success = \'\';
global $wpdb, $PasswordHash, $current_user, $user_ID;
if(isset($_POST[\'task\']) && $_POST[\'task\'] == \'register\' ) {
$pwd1 = (trim($_POST[\'pwd1\']));
$pwd2 = (trim($_POST[\'pwd2\']));
$first_name = (trim($_POST[\'first_name\']));
$last_name = (trim($_POST[\'last_name\']));
$email = (trim($_POST[\'email\']));
$username = (trim($_POST[\'username\']));
if( $email == "" || $pwd1 == "" || $pwd2 == "" || $username == "" || $first_name == "" || $last_name == "") {
$err .= \'Please don\\\'t leave the required fields.<br/>\';
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$err .= \'Invalid email address.<br/>\';
}
if(email_exists($email) ) {
$err .= \'Email already exist.<br/>\';
}
if(username_exists($username) ) {
$err .= \'username already exist.<br/>\';
}
if($pwd1 <> $pwd2 ){
$err .= \'Password do not match.<br/>\';
} else {
$user_id = wp_insert_user( array (\'first_name\' => apply_filters(\'pre_user_first_name\', $first_name), \'last_name\' => apply_filters(\'pre_user_last_name\', $last_name), \'user_pass\' => apply_filters(\'pre_user_user_pass\', $pwd1), \'user_login\' => apply_filters(\'pre_user_user_login\', $username), \'user_email\' => apply_filters(\'pre_user_user_email\', $email), \'role\' => \'subscriber\' ) );
if( is_wp_error($user_id) ) {
$err = \'Error on user creation.\';
} else {
do_action(\'user_register\', $user_id);
$success = \'You\\\'re successfully register\';
}
}
}
?>
<div class="wrapper">
<form method="post">
<h3 class="center h1_head">Create Account.</h3>
<h6 class="center">* Required Fields</h6>
<!--display error/success message-->
<div id="message">
<?php
if(! empty($err) ) :
echo \'<p class="error">\'.$err.\'\';
endif;
if(! empty($success) ) :
echo \'<p class="error">\'.$success.\'\';
endif;
?>
</div>
<div class="row">
<div class="">
<input type="text" value="" name="first_name" id="first_name" class="validate"/>
<label>* First Name</label>
</div>
<div >
<input type="text" value="" name="last_name" id="last_name" class=" validate"/>
<label>* Last Name</label>
</div>
</div>
<div>
<input type="text" value="" name="email" id="email" class="icon_prefix validate" />
<label>* Email</label>
</div>
<div >
<input type="text" value="" name="username" id="username" validate"/>
<label >* Username</label>
</div>
<div >
<input type="text" value="" name="phone" id="phone" validate"/>
<label >Phone</label>
</div>
</div>
<div>
<input type="password" value="" name="pwd1" id="pwd1" class="icon_prefix validate" />
<label>* Password</label>
</div>
<div>
<input type="password" value="" name="pwd2" id="pwd2" validate" />
<label >* Password again</label>
</div>
</div>
<div class="alignleft"><p><?php if($success!= "") { echo $success; } ?> <?php if($err != "") { echo $err; } ?></p></div>
<button type="submit" name="btnregister" class="button btn right" >Register</button>
<input type="hidden" name="task" value="register" />
</form>
</div>
<?php get_footer() ?>
我的问题是:-为什么要做这种按摩?如何解决这个问题?