Re: add/edit combo form--opinions wanted

From: Kreso (kreso_at_purger.com)
Date: 07/13/04


Date: Tue, 13 Jul 2004 15:24:09 +0200

Xenophobe wrote:
> I would like to use the same form for adding new records and editing
> existing records. New form values are contained in $_POST. Database
> values are contained in an associated array. It seems to me that in
> order to use the same form for both tasks, I need to assign the form
> field values to page variables. The flow might look something like
> this:
>
> if $_POST
>
> $variable1 = $_POST['field1'];
> $variable2 = $_POST['field2'];
>
> else if $rows
>
> $variable1 = $row['field1'];
> $variable2 = $row['field2'];
>
> end if
>
> Can someone suggest a simplier way to do this?

isset($_POST['field1']) ? variable1 = $_POST['field1'] : variable1 = '';

but

don't use same form for both operations. You can have 2 forms in single
script(file) each triggered by passed variable

FE:
index.php?action=edit || index.php?action=add

--
kreso