Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:59:10+00:00 2026-05-24T13:59:10+00:00

After getting help from @juhana (thank you again) I ended up with theese codes

  • 0

After getting help from @juhana (thank you again) I ended up with theese codes to validate email input:

validate email:

function validateEmail(){
var a = $("#email").val();
  $.ajax({
  type: "POST",
  url: "check_email.php",
  data: "email="+a,
  success: function(rsp){
   //if it's valid email
   if(rsp == "ok"){
    email.removeClass("error");
    emailInfo.text("");
    emailInfo.removeClass("error");
    return true;
}

else
//if it exists
if(rsp == "exists" ){
 email.addClass("error");
 emailInfo.text("E-mail already in use");
 emailInfo.addClass("error");
 return false;
}

else
//if it's NOT valid
if(rsp == "invalid"){
 email.addClass("error");
 emailInfo.text("Please type a valid E-mail");
 emailInfo.addClass("error");
 return false;
 }
}
});
}

check_email.php

<?php
require_once('db_conn.php');
require_once('is_email.php');

$email = mysql_real_escape_string($_POST['email']);
if (is_email($_POST['email'])){
echo 'ok';

$checkemail = mysql_query("SELECT E_mail FROM orders WHERE E_mail='$email'");
$email_exist = mysql_num_rows($checkemail);

if($email_exist>0){
echo 'exists';
}
}else{
echo 'invalid';
}
?>

Now 2 out of 3 are working the “ok” and the “invalid” ones… the “exists” doesn’t.

What’s wrong here???

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:59:11+00:00Added an answer on May 24, 2026 at 1:59 pm

    by reading your code above, if the email was valid, but existed in the database, it would return “okexists” which would cause your javascript to fail. You’d need to change it to something like this:

    <?php
    
    $email = mysql_real_escape_string($_POST['email']);
    $checkemail = mysql_query("SELECT E_mail FROM orders WHERE E_mail='$email'");
    $email_exist = mysql_num_rows($checkemail);
    
        if (is_email($_POST['email'])){
            if($email_exist) {
                echo "exists";
            }
            else {
                echo "ok";
            }
        } else {
            echo "invalid";
        }
    
    ?>
    

    This allows it to return only the token “exists” when its a valid, but existing email. And only the token “ok” when its a valid, not previously existing email. And of course it returns invalid if it doesn’t pass the is_email() test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help, Python beginner, after getting all the data from xml, data_list = xmlTree.findall('.//data')
I'm trying to create function that provides historical volatility after getting symbol from Yahoo.
Well after getting all the help I could ever hope for, from you guys
After getting a profile hash from the LinkedIn Ruby Gem, but I'm looking for
After getting a struct from C# to C++ using C++/CLI: public value struct SampleObject
I want to search a user from LDAP and after getting the user I
After getting some help on how to measure fysical/actual size of memcached objects to
After getting help on this question , I was led to do better debugging.
After getting good help previously, I have completed my Minesweeper game. However, there is
Hey guys. This is a follow-on from this question : After getting the right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.