Answer the question
In order to leave comments, you need to log in
Why does php Wordpress registration form error occur?
Please tell me here is the php code for the registration page:
<?php
/* Template Name: Registration form */
get_header();
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>
<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="text" id = "txtEmail" name = "txtEmail" placeholder="Email"></div>
</p>
<p>
<label for = "txtPassword">Enter Password</label>
<div><input type="text" id = "txtPassword" name = "txtPassword" placeholder="Password"></div>
</p>
<p>
<label for = "txtPassword2">Enter Password 2</label>
<div><input type="text" id = "txtPassword2" name = "txtPassword2" placeholder="Password 2:"></div>
</p>
</p>
<input type="submit" name = "btnSubmit"/>
</form>
<?php
get_footer();
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question