Insert Database - Foreign Field

Hi I need help in inserting record in my user registration form. my users table is simple

  1. user_id (Primary key - AI)
  2. user_first_name
  3. user_last_name
  4. user_email
    .
    .
    .
  5. user_dep_id (foreign key)
    i have tried to make and insert form and for foreign key field, i inserted a select control that gets all departments fro departments table. i have also tried to set value filed as user_dep_id. but still no record is saved in database. please support on how to all foreign key record.

Everything you have looks correct from what I can see on the images. The only thing that I was not able to see is the name that you have for the select field. The name would need to match what you have in the $_POST for the insert query.

Hi Scott. names and also field type matches as well.

Just to be sure, all three instances of the Name (not to be confused with ID) value must be the same.

and

Hi Ben thanks for help. all three names as you mentioned above were same. However when i used the Form Generator it worked. previously i was adding form groups manually. i still could not find why with manually adding forms groups did not worked. Even with dynamic dynamic event under Server Connection i was getting alert for success, but there was not record in database. same database other tables where working fine


1 Like

Well the generator does that for you, but if you do it manually you really have to make sure that the input field ID’s have a name that is different than the database field name.

image

That is why the generator adds a prefix

Thanks George, i did ID and Name same as POST variable name. that was my mistake i think. I am new to wappler and its a great tool indeed.

1 Like