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

  • SEARCH
  • Home
  • 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 6326789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:09:27+00:00 2026-05-24T17:09:27+00:00

I’m currently trying to implement a feature to check if an email has already

  • 0

I’m currently trying to implement a feature to check if an email has already been taken when a first time user registers for my site. I’m trying to do this with AJAX and use the jQuery tooltip (http://flowplayer.org/tools/tooltip/) plugin to display the message if the e-mail has in fact been taken.

I don’t want to display any message if the e-mail is not taken and don’t want the user to be aware of the fact that I’m checking their e-mail against the database, when they focus out of the e-mail input box. I only want to display a tooltip message if the e-mail has been taken and then make sure it dissapears if they provide a new unique e-mail address.

Here is my code thus far:
register.php (where the form is)

<div class="textboxfrm"><span class="label">Email<span style="color:#FF9000">* </span>              </span><span class="left"></span><span class="center"><input class="required validate-email" id="email" name="email" type="text" style="width:230px;" maxlength="50" />
</span>
<div class="tooltip_email"></div>
</div>

register.js (loaded on document.ready)

jQuery("span.center").tooltip({
    events: {
        span: 'dblclick, dblclick',
        input: 'blur, mouseout',
    },
    effect: "slide", 
    delay: 3000,
    onBeforeShow: function() {
        jQuery("#email").blur(function() { // when focus out

        email = jQuery('#email').attr('value');
        if (email.length > 1){
        jQuery.ajax({
            type: "GET",
            url: "checkusername.php",
            data: "email=" + email,
            success: function(data) {
                jQuery(".tooltip_email").html(data);    
            } 
        }); //end ajax call
       }//end if email > 1
       else { jQuery("span.center").tooltip.hide(); }
        //jQuery(".tooltip_email").hide();
    });//end email blur
    //return false;
   } // end onBeforeShow function
}); //end span.center tooltip

Finally, checkusername.php (where the database is accessed)

<?php
$email = $_GET['email'];

// connection settings stored in file
include("connectionParameters.php");

$connection = mysql_connect($host,$user,$pass)
    or die ("We're sorry, there seems to be an error. Please try again later.");

mysql_select_db($database);

$email = $_GET['email'];

mysql_select_db("testdatabase", $con);

$sql= sprintf("SELECT * FROM Users WHERE email='%s'", mysql_real_escape_string($email));

$result = mysql_query($sql);

$row = mysql_fetch_array($result);

$taken = $row['email'];

if(mysql_num_rows($result) > 0){
    echo "<p>This email belongs to a registered user. Please provide a different email address, or visit <a href='forgot_pass.php'>this</a> page to retrieve your password.</p>";
}
else if(mysql_num_rows($result) < 1) { exit(); }
mysql_close($con);

?>

To make the question a little clearer, the checking of the email is working correctly and I’m seeing the message if an email is taken via the tooltip. However, I’m also seeing the tooltip with no message if I hover over “span.center” or if I change the email to a valid one or If the email is greater than 2 characters. My problem is that I don’t want to see the tooltip box at all under any of those scenarios.

  • 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-24T17:09:28+00:00Added an answer on May 24, 2026 at 5:09 pm

    Do a basic check of the returned data in the AJAX response handler:

    if (data != '') {
        jQuery(".tooltip_email").html(data);    
    }
    

    and only output your “error” message from the PHP script if the email’s actually taken. However, considering doing something a little more fancy, using a JSON data structure, which gives you far more flexibility:

    if(mysql_num_rows($result) > 0) {
        $data = array('error' => true, 'message' => 'Email already taken';
    } else {
        $data = array('error' => false, 'message' => 'Everything A-OK';
    }
    echo json_encode($data);
    

    which you then handle in JS with:

    if (data.error) {
        jQuery(".tooltip_email").html(data.message);    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from

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.