Check if username exists in database with AJAX

前端 未结 4 1932
遥遥无期
遥遥无期 2020-12-03 09:03

So basically, I want to add a feature to my registration form which I will check if that username already exists in the database.

I have a few questions about AJAX -

4条回答
  •  没有蜡笔的小新
    2020-12-03 09:40

    1. if (mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='".$_POST['username']."'")) < 1) { 
          true; 
      } else { 
          false; 
      }
      
    2. you can pass it by get or post methods. in validation.php you just have to write $somevar=$_POST['somevar'];

    3. as I just said you cant pass variables by post or get methods - to do this task, you must us GET.

    i hope i was helpful ;)

提交回复
热议问题