Having problem inserting data in the same row of a DB !!!!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maceved23
Forum Newbie
Posts: 17
Joined: Sun Jul 13, 2003 11:56 pm

Having problem inserting data in the same row of a DB !!!!!!

Post by maceved23 »

Hi, need some help. :wink: I´m creatting a web aplication who post data from diferent forms.

I create a first form, with a validation, in this file I create a part of code:

$expire = 365*24*3600;
setcookie("username","$username",time()+$expire,"/","");
setcookie("smartid","$smartid",time()+$expire,"/","");

session_start();
session_register('username');
session_register('smartid');

The variables I need to insert in my DB in this form are working well.
The problem is in the next form I need to continue inserting data to the same row in my DB.

In my second verify file for my second form I verify if my COOKIE is alive, this validation is working, the fact is when I insert the data of this form to my DB, a new register is create, and I need to continue posting this data to the same register that was create in my first form.

My code for the COOKIE validation is this:

if ($HTTP_COOKIE_VARS['username'] || $HTTP_COOKIE_VARS['smartid'])
{
session_start();
session_register('username');
session_register('smartid');



IF you coul help me it´s really important for me, ´cause is for a client project.

Mail me if someone know a posible solution. maceved23@yahoo.com
THANKS, Mario
pistolfire99
Forum Commoner
Posts: 58
Joined: Thu May 23, 2002 3:18 pm

Post by pistolfire99 »

You cant do that. You cannot use the "INSERT command twice to enter the data in the same row.
What you can do is, use form1 to "INSERT" and then form2 to "UPDATE" the same row.

Suggestion:- Better solution is to "INSERT" all the information in the database in one go. for ex:- form1's elements can be stored on page2 (which also contains form2) and when the user fills out form2, he/she clicks submit and then all the variables from form1 and form2 get INSERTED into the database.
Post Reply