0

I want to add a feature to registration form which will check if that database already exists.
I have a few questions about AJAX. I am working on creating a CMS, and in the from I specify the name of the database to:

 $databse='cms_'.$subdomain;
  1. I want to have a check at the input whether the database exists.
  2. Is there a nice way with bootstrap 3 & jQuery validate plugin to show errors on a form field by displaying a 'green tick' image directly to the right of each form field ?

PS:This is the form http://jsfiddle.net/52VtD/3122/ ! What the problem in my code ?

SpencerX
  • 5,453
  • 1
  • 14
  • 21

2 Answers2

1

Here is an another Stack Overflow post, which figures out the problem with checking if the table exists.

if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'"))==1) 
    echo "Table exists";
else echo "Table does not exist";

If that table exists, just echo true, or if not, then false. Then make AJAX react to the response by displaying a success/failure icon next to the input element.

For those fancy web icons, I'd go for Font Awesome, which is primarily designed for Bootstrap, which you're apparently using in your system.

I find this the easiest and most practical way to make it work. Hope it helped you out, and I highly recommend implementing some of the techniques people have commented on your original post.

Community
  • 1
  • 1
ascx
  • 473
  • 2
  • 13
1

you can select the default database in mysql to eshtablish connection. The default db in mysql is 'mysql'. Then you execute 'show databases' query and check if db already exist.

For dynamic form validation u can use many jquery library and styles ex-http://jqueryvalidation.org/documentation/

Sachin9
  • 135
  • 8