Php AJAX实时注册问题
下面的代码有一个问题。当前代码不起作用,但是如果我删除Php AJAX实时注册问题,php,jquery,ajax,Php,Jquery,Ajax,下面的代码有一个问题。当前代码不起作用,但是如果我删除$.ajax({…在中检查main.php,那么我想要的一切都能起作用 要点是:修复连接到check email.php的$.ajax({…)。 此$.ajax({…应显示密码为chkpass=0;的类似错误的函数 信息:下面的代码必须实时工作-检测按钮上是否存在电子邮件单击onclick=“checkStepOne();”,并且不应删除输入中提供的电子邮件 registration.php <form method="post"
$.ajax({…
在中检查main.php,那么我想要的一切都能起作用
要点是:修复连接到check email.php的$.ajax({…
)。
此$.ajax({…
应显示密码为chkpass=0;的类似错误的函数
信息:下面的代码必须实时工作-检测按钮上是否存在电子邮件单击onclick=“checkStepOne();”,并且不应删除输入中提供的电子邮件
registration.php
<form method="post" action="" id="frmEmailSignup" onsubmit="return submitResform();">
<div class="step step-1">
<section>
<h1><?=$lang['i_040']?></h1>
<div class="col-left">
<p class="prompt"><?=$lang['i_009']?></p>
<ul>
<li>
<a href="system/user-login/google.php" id="googlelogin" class="btn-blue googlelogin"><?=$lang['i_011']?></a>
<div class="clear"></div>
</li>
<li style="padding-top: 0px;">
<a href="system/user-login/microsoft.php" class="btn-blue officelogin" id="officelogin"><?=$lang['i_012']?></a>
<div class="clear"></div>
</li>
</ul>
</div>
<div class="col-right">
<p class="prompt"><?=$lang['i_010']?></p>
<ul>
<li>
<label class="side-label" for="owner[email]"><?=$lang['i_013']?></label>
<input type="email" class="email required" id="owner_email" name="owner[email]" placeholder="<?=$lang['i_013']?>" tabindex="0" onkeyup="return forceLower(this);" style="margin-bottom: 6px;"/>
<?php if ($db->QueryGetNumRows("SELECT * FROM users WHERE login='".$login."' OR email='".$email."' LIMIT 1") > 0) { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['w_024']?></label>
<?php } else { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['i_014']?></label>
<?php } ?>
<span class="check"></span>
</li>
<li class="password-row">
<label class="side-label" for="owner[password]"><?=$lang['i_015']?></label>
<input type="password" class="password required" id="owner_password" name="owner[password]" placeholder="<?=$lang['i_015']?>" tabindex="0"/>
<label class="error"><?=$lang['i_016']?></label>
<span class="check"></span>
</li>
<li class="full">
<button type="button" class="button cta btn-disabled next next-one" tabindex="0" data-plan="register" onclick="checkStepOne();"><?=$lang['i_017']?></button>
</li>
</ul>
</div>
</section>
</div>
<div class="step step-2">
<section>
<h1><?=$lang['i_018']?></h1>
<ul>
<li>
<input type="text" class="password required" id="FirstName" name="owner[FirstName]" placeholder="<?=$lang['i_019']?>" style="width: 48.5%; text-transform: capitalize;"/>
<input type="text" class="password required" id="LastName" name="owner[LastName]" placeholder="<?=$lang['i_020']?>" style="width: 48.5%; float: right; text-transform: capitalize;"/>
<label class="error error-w-form"><?=$lang['i_021']?></label>
<span class="check"></span>
</li>
</br>
<div class="centero" name="gender">
<fieldset class="material-female" style="margin-right: 20px;">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="female">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_022']?></label>
</div>
</div>
</fieldset>
<fieldset class="material-male">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="male">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_023']?></label>
</div>
</div>
</fieldset>
</div>
<li class="full create">
<input type="submit" class="button cta next create-account" value="<?=$lang['i_002']?>" name="register"/>
<p class="agreement"><?=$lang['i_024']?></p>
</li>
</ul>
</section>
<?=$footerLinks?>
</div>
</form>
<script>
function forceLower(strInput) {
strInput.value=strInput.value.toLowerCase();
}
function checkStepOne() {
jQuery("#owner_email").parents("li").find("label.error").hide();
jQuery("#owner_password").parents("li").find("label.error").hide();
jQuery("#owner_email").parents("li").find("span.check").removeClass('chkValid');
jQuery("#owner_password").parents("li").find("span.check").removeClass('chkValid');
var owner_email = jQuery("#owner_email").val();
var owner_password = jQuery("#owner_password").val();
var chkemail = 1;
var chkpass = 1;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (owner_email == "") {
chkemail = 0;
}
if (reg.test(owner_email) == false) {
chkemail = 0;
}
$.ajax({
type: "POST",
url: "check-email.php",
data: datastring,
success: function(owner_email) {
if (owner_email == 0) {
chkemail == 1;
jQuery("#owner_email").parents("li").find("span.check").addClass('chkValid');
} else {
chkemail == 0;
jQuery("#owner_email").parents("li").find("label.error").show();
}
}
});
if (owner_password == "") {
chkpass = 0;
}
if (owner_password.length < 5) {
chkpass = 0;
}
if (chkpass == 1) {
jQuery("#owner_password").parents("li").find("span.check").addClass('chkValid');
} else {
jQuery("#owner_password").parents("li").find("label.error").show();
}
if (chkpass == 1 && chkemail == 1) {
jQuery(".step-1").hide();
jQuery(".step-2").addClass('chkValid').show();
}
return false;
}
function submitResform() {
var FirstName = jQuery("#FirstName").val();
var LastName = jQuery("#LastName").val();
if (FirstName && LastName) {
return true;
} else {
jQuery("#FirstName").parents("li").find("label.error").show();
return false;
}
}
</script>
<?php
$email = $_POST['owner[email]'];
$query = mysql_query("SELECT email FROM users WHERE email = '$email'");
if (mysql_num_rows($query) == 1) {
echo '1';
} else {
echo '0';
}
?>
-
-
-
-
-
-
-
检查main.php
<form method="post" action="" id="frmEmailSignup" onsubmit="return submitResform();">
<div class="step step-1">
<section>
<h1><?=$lang['i_040']?></h1>
<div class="col-left">
<p class="prompt"><?=$lang['i_009']?></p>
<ul>
<li>
<a href="system/user-login/google.php" id="googlelogin" class="btn-blue googlelogin"><?=$lang['i_011']?></a>
<div class="clear"></div>
</li>
<li style="padding-top: 0px;">
<a href="system/user-login/microsoft.php" class="btn-blue officelogin" id="officelogin"><?=$lang['i_012']?></a>
<div class="clear"></div>
</li>
</ul>
</div>
<div class="col-right">
<p class="prompt"><?=$lang['i_010']?></p>
<ul>
<li>
<label class="side-label" for="owner[email]"><?=$lang['i_013']?></label>
<input type="email" class="email required" id="owner_email" name="owner[email]" placeholder="<?=$lang['i_013']?>" tabindex="0" onkeyup="return forceLower(this);" style="margin-bottom: 6px;"/>
<?php if ($db->QueryGetNumRows("SELECT * FROM users WHERE login='".$login."' OR email='".$email."' LIMIT 1") > 0) { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['w_024']?></label>
<?php } else { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['i_014']?></label>
<?php } ?>
<span class="check"></span>
</li>
<li class="password-row">
<label class="side-label" for="owner[password]"><?=$lang['i_015']?></label>
<input type="password" class="password required" id="owner_password" name="owner[password]" placeholder="<?=$lang['i_015']?>" tabindex="0"/>
<label class="error"><?=$lang['i_016']?></label>
<span class="check"></span>
</li>
<li class="full">
<button type="button" class="button cta btn-disabled next next-one" tabindex="0" data-plan="register" onclick="checkStepOne();"><?=$lang['i_017']?></button>
</li>
</ul>
</div>
</section>
</div>
<div class="step step-2">
<section>
<h1><?=$lang['i_018']?></h1>
<ul>
<li>
<input type="text" class="password required" id="FirstName" name="owner[FirstName]" placeholder="<?=$lang['i_019']?>" style="width: 48.5%; text-transform: capitalize;"/>
<input type="text" class="password required" id="LastName" name="owner[LastName]" placeholder="<?=$lang['i_020']?>" style="width: 48.5%; float: right; text-transform: capitalize;"/>
<label class="error error-w-form"><?=$lang['i_021']?></label>
<span class="check"></span>
</li>
</br>
<div class="centero" name="gender">
<fieldset class="material-female" style="margin-right: 20px;">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="female">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_022']?></label>
</div>
</div>
</fieldset>
<fieldset class="material-male">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="male">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_023']?></label>
</div>
</div>
</fieldset>
</div>
<li class="full create">
<input type="submit" class="button cta next create-account" value="<?=$lang['i_002']?>" name="register"/>
<p class="agreement"><?=$lang['i_024']?></p>
</li>
</ul>
</section>
<?=$footerLinks?>
</div>
</form>
<script>
function forceLower(strInput) {
strInput.value=strInput.value.toLowerCase();
}
function checkStepOne() {
jQuery("#owner_email").parents("li").find("label.error").hide();
jQuery("#owner_password").parents("li").find("label.error").hide();
jQuery("#owner_email").parents("li").find("span.check").removeClass('chkValid');
jQuery("#owner_password").parents("li").find("span.check").removeClass('chkValid');
var owner_email = jQuery("#owner_email").val();
var owner_password = jQuery("#owner_password").val();
var chkemail = 1;
var chkpass = 1;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (owner_email == "") {
chkemail = 0;
}
if (reg.test(owner_email) == false) {
chkemail = 0;
}
$.ajax({
type: "POST",
url: "check-email.php",
data: datastring,
success: function(owner_email) {
if (owner_email == 0) {
chkemail == 1;
jQuery("#owner_email").parents("li").find("span.check").addClass('chkValid');
} else {
chkemail == 0;
jQuery("#owner_email").parents("li").find("label.error").show();
}
}
});
if (owner_password == "") {
chkpass = 0;
}
if (owner_password.length < 5) {
chkpass = 0;
}
if (chkpass == 1) {
jQuery("#owner_password").parents("li").find("span.check").addClass('chkValid');
} else {
jQuery("#owner_password").parents("li").find("label.error").show();
}
if (chkpass == 1 && chkemail == 1) {
jQuery(".step-1").hide();
jQuery(".step-2").addClass('chkValid').show();
}
return false;
}
function submitResform() {
var FirstName = jQuery("#FirstName").val();
var LastName = jQuery("#LastName").val();
if (FirstName && LastName) {
return true;
} else {
jQuery("#FirstName").parents("li").find("label.error").show();
return false;
}
}
</script>
<?php
$email = $_POST['owner[email]'];
$query = mysql_query("SELECT email FROM users WHERE email = '$email'");
if (mysql_num_rows($query) == 1) {
echo '1';
} else {
echo '0';
}
?>
功能强制降下(strInput){
strInput.value=strInput.value.toLowerCase();
}
函数checkStepOne(){
jQuery(“#owner_email”).parents(“li”).find(“label.error”).hide();
jQuery(“#owner_password”).parents(“li”).find(“label.error”).hide();
jQuery(#owner_email”).parents(“li”).find(“span.check”).removeClass(“chkValid”);
jQuery(“所有者密码”).parents(“li”).find(“span.check”).removeClass(“chkValid”);
var owner_email=jQuery(“#owner_email”).val();
var owner_password=jQuery(“#owner_password”).val();
var chkemail=1;
var chkpass=1;
变量reg=/^([A-Za-z0-9\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/;
如果(所有者\电子邮件==“”){
chkemail=0;
}
如果(注册测试(所有者电子邮件)=错误){
chkemail=0;
}
$.ajax({
类型:“POST”,
url:“检查email.php”,
数据:datastring,
成功:功能(所有者\电子邮件){
如果(所有者\电子邮件==0){
chkemail==1;
jQuery(“所有者电子邮件”).parents(“li”).find(“span.check”).addClass(“chkValid”);
}否则{
chkemail==0;
jQuery(“#owner_email”).parents(“li”).find(“label.error”).show();
}
}
});
如果(所有者\密码==“”){
chkpass=0;
}
如果(所有者密码长度<5){
chkpass=0;
}
如果(chkpass==1){
jQuery(“#owner_password”).parents(“li”).find(“span.check”).addClass(“chkValid”);
}否则{
jQuery(“#owner_password”).parents(“li”).find(“label.error”).show();
}
如果(chkpass==1&&chkemail==1){
jQuery(“.step-1”).hide();
jQuery(“.step-2”).addClass('chkValid').show();
}
返回false;
}
函数submitResform(){
var FirstName=jQuery(“#FirstName”).val();
var LastName=jQuery(“#LastName”).val();
if(FirstName&&LastName){
返回true;
}否则{
jQuery(“#FirstName”).parents(“li”).find(“label.error”).show();
返回false;
}
}
检查email.php
<form method="post" action="" id="frmEmailSignup" onsubmit="return submitResform();">
<div class="step step-1">
<section>
<h1><?=$lang['i_040']?></h1>
<div class="col-left">
<p class="prompt"><?=$lang['i_009']?></p>
<ul>
<li>
<a href="system/user-login/google.php" id="googlelogin" class="btn-blue googlelogin"><?=$lang['i_011']?></a>
<div class="clear"></div>
</li>
<li style="padding-top: 0px;">
<a href="system/user-login/microsoft.php" class="btn-blue officelogin" id="officelogin"><?=$lang['i_012']?></a>
<div class="clear"></div>
</li>
</ul>
</div>
<div class="col-right">
<p class="prompt"><?=$lang['i_010']?></p>
<ul>
<li>
<label class="side-label" for="owner[email]"><?=$lang['i_013']?></label>
<input type="email" class="email required" id="owner_email" name="owner[email]" placeholder="<?=$lang['i_013']?>" tabindex="0" onkeyup="return forceLower(this);" style="margin-bottom: 6px;"/>
<?php if ($db->QueryGetNumRows("SELECT * FROM users WHERE login='".$login."' OR email='".$email."' LIMIT 1") > 0) { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['w_024']?></label>
<?php } else { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['i_014']?></label>
<?php } ?>
<span class="check"></span>
</li>
<li class="password-row">
<label class="side-label" for="owner[password]"><?=$lang['i_015']?></label>
<input type="password" class="password required" id="owner_password" name="owner[password]" placeholder="<?=$lang['i_015']?>" tabindex="0"/>
<label class="error"><?=$lang['i_016']?></label>
<span class="check"></span>
</li>
<li class="full">
<button type="button" class="button cta btn-disabled next next-one" tabindex="0" data-plan="register" onclick="checkStepOne();"><?=$lang['i_017']?></button>
</li>
</ul>
</div>
</section>
</div>
<div class="step step-2">
<section>
<h1><?=$lang['i_018']?></h1>
<ul>
<li>
<input type="text" class="password required" id="FirstName" name="owner[FirstName]" placeholder="<?=$lang['i_019']?>" style="width: 48.5%; text-transform: capitalize;"/>
<input type="text" class="password required" id="LastName" name="owner[LastName]" placeholder="<?=$lang['i_020']?>" style="width: 48.5%; float: right; text-transform: capitalize;"/>
<label class="error error-w-form"><?=$lang['i_021']?></label>
<span class="check"></span>
</li>
</br>
<div class="centero" name="gender">
<fieldset class="material-female" style="margin-right: 20px;">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="female">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_022']?></label>
</div>
</div>
</fieldset>
<fieldset class="material-male">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="male">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_023']?></label>
</div>
</div>
</fieldset>
</div>
<li class="full create">
<input type="submit" class="button cta next create-account" value="<?=$lang['i_002']?>" name="register"/>
<p class="agreement"><?=$lang['i_024']?></p>
</li>
</ul>
</section>
<?=$footerLinks?>
</div>
</form>
<script>
function forceLower(strInput) {
strInput.value=strInput.value.toLowerCase();
}
function checkStepOne() {
jQuery("#owner_email").parents("li").find("label.error").hide();
jQuery("#owner_password").parents("li").find("label.error").hide();
jQuery("#owner_email").parents("li").find("span.check").removeClass('chkValid');
jQuery("#owner_password").parents("li").find("span.check").removeClass('chkValid');
var owner_email = jQuery("#owner_email").val();
var owner_password = jQuery("#owner_password").val();
var chkemail = 1;
var chkpass = 1;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (owner_email == "") {
chkemail = 0;
}
if (reg.test(owner_email) == false) {
chkemail = 0;
}
$.ajax({
type: "POST",
url: "check-email.php",
data: datastring,
success: function(owner_email) {
if (owner_email == 0) {
chkemail == 1;
jQuery("#owner_email").parents("li").find("span.check").addClass('chkValid');
} else {
chkemail == 0;
jQuery("#owner_email").parents("li").find("label.error").show();
}
}
});
if (owner_password == "") {
chkpass = 0;
}
if (owner_password.length < 5) {
chkpass = 0;
}
if (chkpass == 1) {
jQuery("#owner_password").parents("li").find("span.check").addClass('chkValid');
} else {
jQuery("#owner_password").parents("li").find("label.error").show();
}
if (chkpass == 1 && chkemail == 1) {
jQuery(".step-1").hide();
jQuery(".step-2").addClass('chkValid').show();
}
return false;
}
function submitResform() {
var FirstName = jQuery("#FirstName").val();
var LastName = jQuery("#LastName").val();
if (FirstName && LastName) {
return true;
} else {
jQuery("#FirstName").parents("li").find("label.error").show();
return false;
}
}
</script>
<?php
$email = $_POST['owner[email]'];
$query = mysql_query("SELECT email FROM users WHERE email = '$email'");
if (mysql_num_rows($query) == 1) {
echo '1';
} else {
echo '0';
}
?>
没有人有时间编写这么长的代码。如何创建一个最小的、完整的、可验证的示例,。数据:datastring,
-我看不到任何地方定义了datastring
。我想这个错误会出现在开发人员控制台(F12)中还有。@tyleroper我应该在数据:datastring,
中写些什么?如果你知道答案的话。写在下面,我会批准的。