Forum Moderators: coopster

Message Too Old, No Replies

PHP Forms various steps

How to insert data in 3 steps in the SAME MySQL DATABASE

         

percy05

7:15 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Hello! Here is te question:
My website requires 3 steps to suscribe a new member:
1st Step: New User enters his/her name and other personal data in a form called "form_step1"
2nd Step: He/she pays with bank account or Third-Party Credit Card Service: 2CheckOut.com
3rd Step: He/she confirms the transaction writting the number operation and his/her username and password other in other form called "form_step3"

Getting and sending the data obtained in Step 1 in a MySQL Database named, for example, "Users" has done ok using php in the first form; the problem is Step 3, because it is necessary that the user must insert the transaction operation number and his/her username and password in the form "Step3" to the same database "Users"... Is it possible to insert firstly data through the "form_step1" and then insert data through the "form_step3" to the line in the SAME DATABASE? I think is not possible because each insert creates a new line, and specially when every line (or user insert) has a "User_id" with auto_incrementent primary key column. So, what can I do? Must I create 2 different Mysql databases? Or one database and 2 different tables named "Users_data" and "Confirmation_data"? - In thess to cases, how can I do to "join" or "check" the information obtained in this 2 different databases or tables to finally giving access to a new user to a "Member Zone" in my site?
Thank you very much for your help and support.
Percy

jatar_k

7:21 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you just need to have something that can relate the data ion step 1 and 3.

one possibility is to set a cookie or use a session, then when they are returned to your site your script can verify that user_id and then insert into that row of the table.

If the cookie or session does not exist at that point then you could have the user confirm name and address or email or some other piece of information to be able to find them in your table.

percy05

7:30 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Thanks Jatar K, good idea and I will read about sessions and cookies. I think users can write his/her email and password too... but what you say is possible with only 1 database named for example "users"? Must I create 2 databases or 1 database and 2 tables or not? - Thanks a lot, Percy

jatar_k

7:31 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can do this with 1 db

having them retype their email and password is even better, less work and less chance of error

percy05

8:06 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Great, and I have thought it too, but how can I insert for example the number of banking transaction got in step3 to the original database that has been filled with the data obtained in step1? For example:
Database "users", table "data_users" has the following columns:
1) id_user
2) name
3) username
4) password
5) email
6) ip_user
7) date_insert
8) transaction_number
9) date_transaction

The proccess of the suscription is:

1) 1st Step:
A new user enters his personal data in Form_step1. It gets data from column 1 to column 7 and then register.php inserts it to the database "users", table "data_users"

2) 2nd Step:
The user pays via banking or credit card through 2CheckOut.com and he has a "transaction number". This payment may be in the same or after the date of inserting his data in Step 1.

3) 3rd Step:
USer write the transaction and date of the transaction, and confirms his password and username in Form_step3, say, column 8 and 9. Then register.pho inserts it to the same database "users", table "data_users.

Is it possible to do it? Will it have problems because Form_step1 only sends data column 1 to 7 to a table that has 9 columns to be filled? And, how is it possible to insert column 8 and 9 to the same table? With "If else" command? Or must I create 2 different tables, one for column 1 to 7 and the other to columns 8 and 9? If so, how do I connect these 2 new tables?
Or maybe there is an easier way to do this Suscription proccess?
Thanks a lot for your patience and help.
Percy

jatar_k

8:30 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you would use an update [dev.mysql.com] query

something like

update data_users set transaction_number='x', date_transaction='y' where user_id='z';

obviously you would substitute x, y and z with their appropriate values

percy05

8:42 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Thanks Jatar K, i will try what you recommend
Thanks
Percy