在没有jQuery的情况下检查php中的用户可用性

在没有jQuery的情况下检查php中的用户可用性,php,Php,我是php的初学者,我想知道不使用jQuery(我指的是纯php/html)就可以进行用户名可用性检查吗?我尝试使用$\u POST['username']=$username或使用$\u SESSION['username']=$username,然后使用$\u POST['username']=$\u SESSION['username']来防止用户名输入框中的用户名被删除(在点击检查用户名按钮后),但失败了。我知道这可能听起来很傻,但也许还有别的办法?以下是第一个代码: <!

我是php的初学者,我想知道不使用jQuery(我指的是纯php/html)就可以进行用户名可用性检查吗?我尝试使用$\u POST['username']=$username或使用$\u SESSION['username']=$username,然后使用$\u POST['username']=$\u SESSION['username']来防止用户名输入框中的用户名被删除(在点击检查用户名按钮后),但失败了。我知道这可能听起来很傻,但也许还有别的办法?以下是第一个代码:

    <!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>New Member</title>
    </head>

    <body>
        <center>
            <h3>@------------ Create New Account ------------@</h3>
            <form method="post" name="form1">
                <table width="299" border="0">
                  <tbody>
                    <tr>
                      <td width="62">Username</td>
                      <center><td>:<br></td></center>
                      <td colspan="2"><input type="text" name="username">
                      <input type="submit" name="check" value="Check">

                      <?php
                        include('connection.php');
                        if(isset($_POST['check']))
                        {
                            $userchk=$_POST['username'];
                            $query="select username from login where username='$userchk'";
                            $check=mysqli_query($connection,$query);
                            if(mysqli_num_rows($check)==1)
                            {
                                echo "Username already in used";
                            }
                            else
                            {
                                $_POST['username']=$userchk;
                                echo "Username available";
                            }
                        }
                        ?></td>
                    </tr>
                   </tbody>
                 </table>
             </form>
             <form method="post" name="form2" action="signup_process.php">
                <table>
                    <tbody>
                    <tr>
                      <td height="66">Email</td>
                      <center><td>:</td></center>
                      <td colspan="2"><input type="text" name="email"></td>
                    </tr>
                    <tr>
                        <td height="74">Sites</td>
                      <center><td>:</td></center>
                        <td colspan="2"><input type="text" name="sites"></td>
                    </tr>
                    <tr>
                        <td>Password</td>
                        <center><td>:</td></center>
                        <td colspan="2"><input type="text" name="password"></td>
                    </tr>
                    <tr>
                      <td></td>
                      <center>
                      <td width="6">&nbsp;</td>
                      <td width="72"><input type="submit" name="submit" value="Submit"></td>
                      <td width="115"><input type="reset" name="reset" value="Reset"></td>                                    
                      <td width="22">&nbsp;</td>
                      </center>
                    </tr>
                </tbody>
              </table>
        </form>
        </center>
    </body>
</html>

新成员
@------------创建新帐户------------@
用户名
:
电子邮件 : 地点 : 密码 :
第二个代码:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>New Member</title>
    </head>

    <body>
        <center>
            <h3>@------------ Create New Account ------------@</h3>
            <form method="post" name="form1">
                <table width="299" border="0">
                  <tbody>
                    <tr>
                      <td width="62">Username</td>
                      <center><td>:<br></td></center>
                      <td colspan="2"><input type="text" name="username">
                      <input type="submit" name="check" value="Check">

                      <?php
                        include('connection.php');
                        if(isset($_POST['check']))
                        {
                            $userchk=$_POST['username'];
                            $query="select username from login where username='$userchk'";
                            $check=mysqli_query($connection,$query);
                            if(mysqli_num_rows($check)==1)
                            {
                                echo "Username already in used.";
                            }
                            else
                            {
                                session_start();
                                $_SESSION['username']=$userchk;
                                $_POST['username']=$_SESSION['username'];
                                echo "Username available.";
                            }
                        }
                        ?></td>
                    </tr>
                   </tbody>
                 </table>
             </form>
             <form method="post" name="form2" action="signup_process.php">
                <table>
                    <tbody>
                    <tr>
                      <td height="66">Email</td>
                      <center><td>:</td></center>
                      <td colspan="2"><input type="text" name="email"></td>
                    </tr>
                    <tr>
                        <td height="74">Sites</td>
                      <center><td>:</td></center>
                        <td colspan="2"><input type="text" name="sites"></td>
                    </tr>
                    <tr>
                        <td>Password</td>
                        <center><td>:</td></center>
                        <td colspan="2"><input type="text" name="password"></td>
                    </tr>
                    <tr>
                      <td></td>
                      <center>
                      <td width="6">&nbsp;</td>
                      <td width="72"><input type="submit" name="submit" value="Submit"></td>
                      <td width="115"><input type="reset" name="reset" value="Reset"></td>                                    
                      <td width="22">&nbsp;</td>
                      </center>
                    </tr>
                </tbody>
              </table>
        </form>
        </center>
    </body>
</html>

新成员
@------------创建新帐户------------@
用户名
:
电子邮件 : 地点 : 密码 :

谢谢。

我认为您的问题不清楚,需要您复制代码以获得更多澄清。是的,我知道,但我想知道并尝试一下,我是否可以在没有ajax或javascript的情况下,仅在php中完成这项工作。我想如果你认为你的问题不清楚,需要你复制你的代码以获得更多的澄清,那将很酷。是的,我知道,但我想知道并尝试一下,我是否可以在没有ajax或javascript的情况下做到这一点,只使用php。如果你能的话,我想会很酷的