我有一个注册表,我为检查数据库中的电子邮件是否存在提供了一些条件,但是当我用现有的电子邮件创建一个新帐户时,它会返回1,即(电子邮件已存在)并且还可以,但是当我创建一个新帐户时收到新的电子邮件后,它会再次返回1 ..,并且应该返回我-> 4,用于(成功创建帐户)请参见下面的代码:
$('#acord').on('change', function(){
this.value = this.checked ? 1 : 0;
$("#formreg").submit(function(event) {
event.preventDefault();
$(".inreg").html('<i class="fa fa-spinner fa-pulse"></i> Verificam informatiile..');
var $form = $(this),
acord = $form.find("[type='checkbox'][name=acord]").val(),
nume = $form.find("[type='text'][name=nume]").val(),
email = $form.find("[type='email'][name='email']").val(),
parola = $form.find("[type='password'][name='parola']").val(),
varsta = $form.find("[type='text'][name='varsta']").val(),
url = 'inc/sql/register-user.php';
setTimeout(function() {
var posting = $.post(url, {
nume: nume,
email: email,
parola: parola,
varsta: varsta,
acord: acord
});
posting.done(function(data) {
if (data == 1) {
swal({
title: "Adresa de mail exista",
text: "Adresa de email "+email+" este deja folosita.",
type: "error",
timer: 4000,
showConfirmButton: false
});
$(".inreg").html('INREGISTREAZA-TE');
} else if (data == 2) {
swal({
title: "Ups!",
text: "Adresa de email nu este valida.",
type: "error",
timer: 4000,
showConfirmButton: false
});
$(".inreg").html('INREGISTREAZA-TE');
} else if (data == 3) {
swal({
title: "Ups!",
text: "Parola prea lunga, trebuie sa contina intre 5 si 10 caractere. ",
type: "error",
timer: 4000,
showConfirmButton: false
});
$(".inreg").html('INREGISTREAZA-TE');
} else if (data == 4) {
swal({
title: "Felicitari! " + nume + "",
text: "Contul a fost inregistrat in baza noastra de date. Nu uitati sa adaugati momentele. Va dorim mult succes!",
type: "success",
timer: 2100,
showConfirmButton: false
});
$(".inreg").html('<i class="fa fa-spinner fa-pulse"></i> Va logam automat in cont..');
setTimeout(function() {window.location.href = "?p=contul-meu";}, 3000);
} else if (data == 5) {
swal({
title: "Termeni si conditii neacceptate!",
text: "Ne pare rau, dar ca sa te poti inregistra pe aceasta platforma trebuie sa fi de acord cu termenii si conditiile noastre!",
type: "warning",
timer: 4300,
showConfirmButton: false
});
}
$(".inreg").html('INREGISTREAZA-TE');
})
}, 3000);
});
}).change();
$('#acord').on('change', function(){
this.value = this.checked ? 1 : 0;
$("#formreg").submit(function(event) {