Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2010
    Location
    Risalpur/ Pakistan
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to check email/user ID avalibilty???


    everybody... i hope u all ppl will be fine and enjoying.

    i m new user here.. if i did any mistakes. i m sorry for that..

    Dear i m making a user Registration form... in which i have added a button CHECK AVAILIBILTY
    this button work is to chck in DATABASE that the user Input email address or ID is availble are not..???

    i m also using php language within the javascript... but i m not getting, how to assign php variable variable value to javascript variable??? plz help me

    i know the mysql query..

    <?php
    $query=mysql_num_rows(mysql_query("SELECT user_email FROM user_area WHERE user_email='email'"))

    /*1st email will be taken from input txt field and then match with database. if $query is equal to 1 then its mean email/ID not available, if $query is equal to zero its mean not avalibl.
    */


    ?>

    <script language='javascript'>
    function EMAIL_AVALIBLE()
    {
    var email_chk="document.getElementById('email').value";


    // plz tell me what i do here

    }
    <form action="register_act.php" method="POST" name="register">
    E-Mail Address :
    <input type='text' name='email' id="email" >
    <input type='button' name='Check' onClick='EMAIL_AVALIBLE()' value='Check E-Mail Avalibility' >

    </form>



  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    London
    Posts
    225
    Thanks
    16
    Thanked 2 Times in 2 Posts
    how to assign php variable variable value to javascript variable???
    I presume you didn't mean 'variable variable', as I don't see any variable variables in your code, but do you mean that you want the email address that the user has typed into your input field to become the value of var email_chk?

    If so, then your code should work.

    What is returned when you add to the function...?
    Code:
    alert('email_chk = '+email_chk);

  • #3
    New Coder
    Join Date
    Feb 2010
    Location
    Risalpur/ Pakistan
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    dear i want this..

    for example a user put the email (qazi@yahoo.com)

    below the email address field i show the button (chek availbilty)

    when user click at that button a javascript Function
    will be called (CHECK_AVALIBLE) as i mention in my above Post..

    so there i m not getting that how to match user input Email address with the database address by using javascript and php..

    if the user email address match so its mean email already registerd...
    a message will display.. email already regsterd....

    if not match with the database email
    a message will display.. email avalible....

    plz tell me that how do this....
    Last edited by hamayun_4u2004; 04-01-2010 at 12:39 PM.

  • #4
    Regular Coder
    Join Date
    Feb 2007
    Location
    London
    Posts
    225
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Sorry, I misunderstood you before.

    OK, try this:
    Code:
    $(document).ready(function(){
      function instantiateRequest() {
        var ajaxRequest;  // The variable that makes Ajax possible!
        //Browser Support Code
        try {
    // Opera 8.0+, Firefox, Safari
          ajaxRequest = new XMLHttpRequest();
    //alert("Your browser is Opera 8.0+, Firefox, or Safari");
        } catch (e) {
    // Internet Explorer Browsers
          try {
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
            try {
              ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
              alert("Oops! You seem to be having browser trouble!");
              return false;
            }
          }
        }
        
        return ajaxRequest;
      }
      
    
    
    function EMAIL_AVALIBLE() {
    var email_chk="document.getElementById('email').value";
    
    check_email_avail(email_chk);
    }
    
    
      function check_email_avail(email) {
        ajaxRequest = instantiateRequest();
        ajaxRequest.onreadystatechange = function() {// Create a function that will receive data sent from the server
          if (ajaxRequest.readyState == 4) {
            var htmlResponse = ajaxRequest.responseText;
            //Do stuff here with any output from the php.
    //In your case, this'll be simply telling the user whether or not that address was available.
    
          }
        }
    
        ajaxRequest.open("GET", PATH_TO_A_FILE_CONTAINING_MYSQL_REQUEST, true);
        ajaxRequest.send(null);
      }
    });

  • #5
    Regular Coder
    Join Date
    Feb 2007
    Location
    London
    Posts
    225
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Oops...

    This:
    Code:
    ajaxRequest.open("GET", PATH_TO_A_FILE_CONTAINING_MYSQL_REQUEST, true);
    should have been:

    Code:
    ajaxRequest.open("GET", PATH_TO_A_FILE_CONTAINING_MYSQL_REQUEST+'?email='+email, true);
    Then the file with the MySQL query in needs:
    PHP Code:
    if (!empty($_GET['email'])) {
    $requestedEmail $_GET['email'];

    //now $requestedEmail contains the email to put in your MySQL query

    Last edited by cfructose; 04-01-2010 at 01:03 PM. Reason: typo again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •