正如您在该链接上看到的:
https://cixme.deniz-tasarim.site/video-upload/
单击提交按钮后,wp表示我的电子邮件无效,但我输入了有效的电子邮件。
Array ( [email_valid] => Email has no valid value )
相关代码:
if(is_email($email)) {
$error[\'email_valid\'] = "Email has no valid value";
}
完整代码:
<?php
/* Template Name: Video Upload */
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>
<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 get_footer(); ?>