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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:43:17+00:00 2026-06-12T16:43:17+00:00

echo <form method=’post’ action=’regprocess.php’ id=’registerform’>; echo ‘<fieldset class=register>’; echo<h2>Register</h2>; echo <ul>; echo ‘<li><label for=FirstName>First

  • 0
    echo "<form method='post' action='regprocess.php' id='registerform'>";
        echo '<fieldset class="register">';
        echo"<h2>Register</h2>";
            echo "<ul>";
                    echo '<li><label for="FirstName">First Name: </label> <input type="text" name="FirstName" id="FirstName"></li>';
                    echo '<li><label for="LastName">Last Name: </label> <input type="text" name="LastName" id="LastName"></li>';
                    echo '<li><label for="Email">Email: </label><input type="email" name="Email" id="Email"></li>';
                    echo '<li><label for="Username">Username: </label><input type="text" name="Username" id="Username"></li>';
                    echo '<li><input type="button" id="check_username_availability" value="Check Availability"></li>';  
                    echo '<div id="username_availability_result"></div>'; 
                    echo '<li><label for="Password">Password: </label><input type="password" name="Password" id="Password"></li>';
                    echo '<li><input type="submit" value="Register"></li>';
                    echo "</ul>";
        echo "</fieldset>";
        echo "</form>";


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
$(document).ready(function() {  

        var checking_html = 'Checking...';  

        //when button is clicked  
        $('#check_username_availability').click(function(){  
            //run the character number check  
                $('#username_availability_result').html(checking_html);  
                check_availability();  
        });  

  });  

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

        //get the username  
        var username = $('#username').val();  

        //use ajax to run the check  
        $.post("check_username.php", { username: username },  
            function(result){  
                //if the result is 1  
                if(result == 1){  
                    //show that the username is available  
                    $('#username_availability_result').html(username + ' is Available');  
                }else{  
                    //show that the username is NOT available  
                    $('#username_availability_result').html(username + ' is not Available');  
                }  
        });  

}
</script>


<?php
$conn = new mysqli('sapphire', 'cgreenheld', '', 'cgreenheld_dev');
$username = mysqli_real_escape_string($conn, $_POST['Username']);  

//mysql query to select field username if it's equal to the username that we check '  
$usernameresult = 'Select Username from User where Username = "'. $username .'"'; 
$uresult = $conn->query($usernameresult); 

//if number of rows fields is bigger them 0 that means it's NOT available '  
if($uresult->num_rows==1) {  
    //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;  
}  
?>

Hi everyone, I’m trying to check if a username is in the database, and I’m not sure quite what’s wrong with my code, when it retrieves the stuff from the database it just always shows “undefined is not avaliable” so for some reason it’s not retrieving the username, wondering if anyone could help me? I’m really stuck.. The php is in a different file just for anyone who wanted to know.

  • 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-06-12T16:43:18+00:00Added an answer on June 12, 2026 at 4:43 pm

    You have an Uppercase ‘Username’ id attribute on your input and you are selecting it with a lowercase ‘username’ in jquery:

    echo '<li><label for="Username">Username: </label><input type="text" name="Username" id="Username"></li>';
    
    var username = $('#username').val();
    

    and

    you are posting lowercase ‘username’ to php and trying to access it with an uppercase ‘Username’

    $.post("check_username.php", { username: username }, 
    
    $username = mysqli_real_escape_string($conn, $_POST['Username']);  
    

    Set them all to lowercase or uppercase and you should be OK

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

Sidebar

Related Questions

I write two file main.php and download.php . main.php echo<form action='download.php' method='post'> for(i =
I want to make this form: echo '<form method=post action=ratinghandler.php style=width: 250px> <input type=hidden
<form method = post action = <?php echo $_SERVER['PHP_SELF']; ?> /> Username:<input type =
<?php $var = arbitrary; echo <<<_END <form method = post action = feed.php> <input
I am trying to echo the action for my form if a post equals
I have a PHP form that I've set up with a POST method. When
here is the form: <?php echo form_open('locker_settingstwo/processform', array('class' => 'form-horizontal')); ?> <div class =
this is my HTML: <?php echo form_open(base_url().'admin'); ?> <div class=row username> <span class=icon></span> <input
Please see my question in the template section below: Form (showSuccess): <?php echo form_tag('job/salarySubmit')
<?php echo validation_errors(); ?> <?php echo form_open('verifylogin'); ?> <label for=username>Username:</label> <input type=text size=20 id=username

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.