Моя настраиваемая форма регистрации отлично работает на WordPress, но когда я изменил ее и включил в модальную, она не работает.
ниже форма работает безупречно:
<?php
global $wpdb;
if ($_POST) {
$username = $wpdb->escape($_POST['txtUsername']);
$email = $wpdb->escape($_POST['txtEmail']);
$password = $wpdb->escape($_POST['txtPassword']);
$ConfPassword = $wpdb->escape($_POST['txtConfirmPassword']);
$error = array();
if (strpos($username, ' ')!==FALSE) {
$error['username_space'] = "Username has Space";
}
if(empty($username)) {
$error['username_empty'] = "Needed Username must";
}
if(username_exists($username)) {
$error['username_exists'] = "Username already exists";
}
if(!is_email($email)) {
$error['email_valid'] = "Email has no valid value";
}
if(email_exists($email)) {
$error['email_existence'] = "Email already exists";
}
if (strcmp($password, $ConfPassword) !==0) {
$error['password'] = "Password didn't match";
}
if (count($error) == 0) {
wp_create_user($username,$password,$email);
echo "User created successfully";
exit();
}
else print_r($error);
}
?>
<form method="post">
<p>
<label for="txtUsername">Enter Username</label>
<div>
<input type="text" id="txtUsername" name="txtUsername" placeholder="Username"/>
</div>
</p>
<p>
<label for="txtEmail">Enter Email</label>
<div>
<input type="email" id="txtEmail" name="txtEmail" placeholder="Email"/>
</div>
</p>
<p>
<label for="txtPassword">Enter Password</label>
<div>
<input type="password" id="txtPassword" name="txtPassword" placeholder="Password"/>
</div>
</p>
<p>
<label>Enter Confirm Password</label>
<div>
<input type="password" id="txtConfirmPassword" name="txtConfirmPassword" placeholder="Confirm Password"/>
</div>
</p>
<input type="submit" name="btnSubmit"/>
</form>
но это Форма не работает. Она не сохраняет пользователя и не замечает каких-либо ошибок даже на php после предупреждения об удалении.
Как я могу ее решить? В чем проблема? Можете ли вы сказать мне решение? Я надеюсь, что вы решите. Спасибо за ваши решения.
Я называю это так:
<a href="#" data-toggle="modal" data-target=".bs-example-modal-lg" data-whatever="@mdo"><i class="fa fa-edit text-thm2"></i> Sign Up</a>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog">
<?php get_template_part( 'include/sign-up' ); ?>
</div>
здесь регистрация. php:
<?php
global $wpdb;
if ($_POST) {
$username = $wpdb->escape($_POST['txtUsername']);
$email = $wpdb->escape($_POST['txtEmail']);
$password = $wpdb->escape($_POST['txtPassword']);
$ConfPassword = $wpdb->escape($_POST['txtConfirmPassword']);
$error = array();
if (strpos($username, ' ')!==FALSE) {
// $error['username_space'] = "Username has Space";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if(empty($username)) {
$error['username_empty'] = "Needed Username must";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if(username_exists($username)) {
$error['username_exists'] = "Username already exists";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if(!is_email($email)) {
$error['email_valid'] = "Email has no valid value";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if(email_exists($email)) {
$error['email_existence'] = "Email already exists";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if (strcmp($password, $ConfPassword) !==0) {
$error['password'] = "Password didn't match";
?>
<script>
alert("Username has Space");
</script>
<?php
}
if (count($error) == 0) {
wp_create_user($username,$password,$email);
echo "User created successfully";
?>
<script>
alert("Username has Space");
</script>
<?php
exit();
}
else {
print_r($error);
?>
<script>
alert("Username has Space");
</script>
<?php
}
}
?>
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-center" id="exampleModalLabel">Register</h4>
<p class="text-center">Sign in and choose your service to have access to all our service.</p>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12 col-md-8 col-md-offset-2">
<form class="ulockd-reg-form text-center row">
<h3> <span class="flaticon-house-key"></span> Register</h3>
<p>Join our community today:</p>
<div class="col-md-12">
<div class="form-group">
<input type="text" class="form-control" id="exampleInputNamexa" placeholder="Username" name="txtUsername">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="email" class="form-control" id="exampleInputEmailx" placeholder="Email" name="txtEmail">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="password" class="form-control" placeholder="Password" name="txtPassword">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="password" class="form-control" placeholder="Repeat password" name="txtConfirmPassword">
</div>
</div>
<div class="col-md-12">
<div class="form-group text-center">
<button type="submit" class="btn btn-default ulockd-btn-thm2" name="btnSubmit">Sign Me Up</button>
</div>
</div>
<div class="col-xxs-12 col-xs-5 col-sm-5 col-md-5">
<a href="#" class="btn btn-lg btn-primary btn-block color-white">Facebook</a>
</div>
<div class="col-xxs-12 col-xs-2 col-sm-2 col-md-2">
<a href="#">OR</a>
</div>
<div class="col-xxs-12 col-xs-5 col-sm-5 col-md-5">
<a href="#" class="btn btn-lg btn-info btn-block color-white">Google</a>
</div>
</form>
</div>
</div>
</div>
<!-- modal footer start here-->
</div>
</div>