I have a user registration form that submits to MySQL. The user form collects info in this order: id name email state zip cookid $query1="INSERT INTO members(name,email,city,state,zip,cookid) VALUES('$_POST[name]','$_POST[email]','$_POST[city]','$_POST[state]','$_POST[zip]','$cookid')"; Code (markup): I want to be able to have the DB table look like this: id name attribute1 email state zip cookid The question becomes how do I submit the top set of information and not have it in the wrong fields in the DB? Is there some sort of null value i have to add to the string? thx
Since you only insert it in the name,email,city,state,zip,cookid fields the attribute1 will be left blank or the dafault value.
The ID field works best if you declare it as " int(11) NOT NULL auto_increment", you need to declare it as " PRIMARY KEY (ID)" in order for it to increase . If you like to avoide null you could use "varchar(50) NOT NULL default 'test'" to avoide null in database Hope this help a bit
If you don't include attribute1 on your form, the value will be blank or filled with whatever is in your insert command. Also, you should set your 'id' field as the primary key & to auto increment. That will prevent you from having to look up the previous records number and manually setting the id. I also discovered it helps to set unique ID names for each table. cust_id prod_id user_id etc... don't use 'rowid' or 'id' etc.. you'll get confused (at least I did :-/)