Web Form - PHP, AJAX, MySQL, and JSON?
Posted on 2010-11-18
I am having trouble getting my head wrapped around the initial stages of project I am doing for on intranet page.
What I Have:
A database of customers hosted on the local network with Ubuntu/MySQL.
What I Need:
A web form that loads a customer record from the mysql database in order to present an interface that makes editing the database easy. The AJAX would serve the purpose of form field validation, though its primary purpose would be to verify certain fields are unique to their respective field across the entire database.
What I Am Requesting
A sample solution. A php web page that connects to a mysql database and loads a recordset/customer record. As the form is filled out, certain fields will be checked for basic validity (not empty/null, follows email address format, follows phone number format, etc...), a couple of other fields will be checked against the database to ensure the value is unique (e.g. a customer's username). If it is not unique, return an alert back to the client letting them know that another user is currently using that username and to please select assign a different/unique username. I also would like to be able to trigger alerts based off of database field values if a sample of how this would be accomplished could be provided. I have been looking at using jquery, but I have not been able to wrap my head around everything yet.
Sample Dbase Fields:
Name, Client Type, Email Address, Phone Number, Username, Password, Credit Status
When the form loads initially, display an alert if credit status is set to hold, otherwise wait for input.
When entering a new customer (vs. editing an existing one) indicate name field is not valid until it is no longer empty.
When email address field is edited check for conformity to email address spec.
When phone number is edited, check for conformity to email address spec
When username is input, make sure the username is unique (no other customers have the same username)
Once I get the concept of how to make the fields interact, I will add all the other fields of the dbase and customize other alerts/dialog boxes etc.. I also plan to put the jquery datepicker in since some of the other fields contain dates, but I think I should be able to get that once I see how the to make the form post back with AJAX.
Please ask any questions...