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 7644467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:41:45+00:00 2026-05-31T09:41:45+00:00

Basically i want a form that retrieves the value 1 or 0 to see

  • 0

Basically i want a form that retrieves the value 1 or 0 to see whether an email exists within the form, and i also want to retrieve the name of the ‘username’ column which is on the same row as the email.

Here is the javascript/php script ( i start here ) :
http://pastebin.com/zB0Umyyb

<!DOCTYPE html>
<html>
<head>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

  <script>
  $(document).ready(function() {
    $("#tabs").tabs();
  });
  </script>
<script type="text/javascript">


  $(document).ready(function() {


                //the min chars for username
                var min_chars = 3;

                //result texts
                var characters_error = 'Minimum amount of chars is 3';
                var checking_html = 'Checking...';

                //when button is clicked
                $('#check_email_availability').click(function(){
                        //run the character number check
                        if($('#email').val().length < min_chars){
                                //if it's bellow the minimum show characters_error text
                                $('#email_availability_result').html(characters_error);
                        $(checking_html).hide();
                        }else{                 
                                //else show the cheking_text and run the function to check
                                $('#email_availability_result').html(checking_html);
                                check_availability();
                                $(checking_html).hide();
                        }
                });


  });

//function to check username availability      
function check_availability(){

                //get the username
                var email = $('#email').val();
                //use ajax to run the check
                $.post("check_email.php", { email: email },
                        function(result){
                                //if the result is 1
                                if(result == 1){
                                        //show that the username is available
                                        $('#email_availability_result').html('<span class="is_available"><b>' +email + '</b> is Available</span>');
                                }else{
                                        //show that the username is NOT available
                                        $('#email_availability_result').html('<span class="is_not_available"><b>' +email + '</b> has already been refered</span>');
                                }
                });

}  
</script>
</head>
<body style="font-size:62.5%;">
<?
require ("config/config.php");
$result = mysql_query('select * from refer where email = "user@example.com" AND referred = "true"');
$row = mysql_fetch_array($result);
$usercheck = $row['username'];
?>
<div id="tabs">
    <ul>
        <li><a href="#fragment-1"><span>Refer</span></a></li>
        <li><a href="#fragment-2"><span>Referal History</span></a></li>
        <li><a href="#fragment-3"><span>Rewards</span></a></li>
    </ul>
    <div id="fragment-1">
<form>
  <p>Minecraft User:
  <input type='text' id='username'>
    </p>
  <p>Email Address:
  <input type='text' id='email'> <input type='button' id='check_email_availability' value='Check Availability'>
  </p>
</form>
  <script>
  $(document).ready(function() {
    $("button").button();
  });
  </script>
  <button> Refer! </button>
  </br>
  <div id='username_availability_result'></div>
  </br>
<div id='email_availability_result'></div>
  </div>
    <div id="fragment-2">
<table border="1">
<tr>
<th>User</th>
<th>Referal Request</th>
</tr>
<tr>
<td>MrMan121</td>
<td>Pending</td>
</tr>
<tr>
<td>olimoli123</td>
<td>Accepted</td>
</tr>
</table>
    </div>
    <div id="fragment-3">
Rewards include:
dadadad.
    </div>
</div>
</body>
</html>

And here is the php script it talks to:
http://pastebin.com/tQppn84s

<?php
//connect to database
require ("config/config.php");

//get the username
$email = mysql_real_escape_string($_POST['email']);

//mysql query to select field username if it's equal to the username that we check '
$result = mysql_query('select email from refer where email = "'. $email .'" AND referred = "true"');
$row = mysql_fetch_array($result);
$usercheck = $row['username'];
//if number of rows fields is bigger them 0 that means it's NOT available '
if(mysql_num_rows($result)>0){
        //and we send 0 to the ajax request
        echo 0;
}else{
        //else if it's not bigger then 0, then it's available '
        //and we send 1 to the ajax request
        echo 1;
}

?>

and $usercheck should check for the username.

  • 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-31T09:41:46+00:00Added an answer on May 31, 2026 at 9:41 am

    You just need to change the formatting of the response, and modify how it’s handled on receipt. For instance, instead of just echo 0; you could do something like (I wasn’t sure how you wanted username used, so that was just a guess)

    echo '{"available":false, "username":"'.$usercheck.'"}';

    then, in your HTML page, you would

    $.post("check_email.php", { email: email },
    function(result){
        response=jQuery.parseJSON(result);
        //if the result is 1
        if(response.available){
            //show that the username is available
            $('#email_availability_result').html('<span class="is_available"><b>' +email + '</b> is Available</span>');
        }else{
            //show that the username is NOT available
            $('#email_availability_result').html('<span class="is_not_available"><b>' +email + '</b> has already been referred by user '+response.username+'</span>');
    });
    

    and, for the IS available case, you’d

    echo '{"available":true}';

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

Sidebar

Related Questions

Basically I want to develop a BHO that validates certain fields on a form
I want to create a javascript form that basically has a bunch of text
I have this form. Basically what I want is to send a auto-response with
So, what I want is basically to attach a javascript handler to a form,
Basically i have a form where a studentID is inputted, i then want to
Basically, I want to insert rows in the form InventJournalTransfer. I added a menuitem
I have a html form that is basically vertical but i really have no
Is it possible to retrieve the infomation about the webpage that sent a form
I have a select form field that I want to mark as readonly, as
What I want to do is basically send some form of id with my

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.