Validating the Form with MySQL

Asked By 0 points N/A Posted on -

Can anyone help me regarding the issue of MySQL form validator that I want to apply to my web page?

How can I validate the form in case if the username in the database already exists when a new user wants to create the account?

I need the expert opinion.

Answered By 0 points N/A #160072

Validating the Form with MySQL


You need to create an SQL which will filter the database to look for username in your table which is the same to the username that the user enters. To do that I used PHP as programming code to connect to MySQL database and validate the user.

<? PHP

$ username =$_POST [username];

If (MySQL_num_rows (MySQL_query ("SELECT fldusername FROM users WHERE fldusername = '$ username '")))


$msg=$msg."username already exists";



If data on your database table matched to user inputted username then it will give an error message saying that the username already exist. You can use this query in any filed also.

Hope this helped you.

Login/Register to Answer

Related Questions