php - User already exists and please fill in the form -
This is a code that is yet to register a user
Now I Required for:
- To return an error message if the username has already been taken
- If the fields are empty, / Li>
Here is the code:
// ============= Configure server and database ====== = $ Host = 'localhost'; $ User = 'root'; $ Password = 'revolve'; // ============= DATA BASE INFORMATION ================= Database = 'DBSC'; $ Conn = mysql_connect ($ host, $ user, $ password) or die ('server information is not correct'); // Install connection with server mysql_select_db ($ database, $ conn) or die ('database information is not correct'); // =============== End server configuration ========================== Registration script start ========== $ username = mysql_real_escape_string ($ _ POST ['txtUser']); $ Password = mysql_real_escape_string ($ _ POST ['txtPassword']); If (isset ($ _ POST ['btnRegister'])) // === When I set the button 1 or to press the press button {$ query = "Enter in bladmin (admin_usr_name, admin_pwd) value ('$ UserName ',' $ password ') "; $ Res = mysql_query ($ query); Header ('location: success_register.php'); }
Any help would be appreciated
I think Please help it ...
// blank empty (! Trim ($ user name) ||! Trim ($ password)) {// some fields are still empty} Other {// there is no empty field // check user exists $ checkQuerySql = "select 'from' bladmin 'Where' admin_usr_name` = '$ userName'"; $ CheckQuery = mysql_query ($ checkQuerySQL); If (mysql_fetch_assoc ($ checkQuery)) {// user exists} other {// user does not exist}}
Comments
Post a Comment