PHP: How can I use one form for two things?

Bergel M

New member
I have a form with fields like this:

<input type="text" name="item_name" value="<?PHP echo $_POST['item_name'];?>" />

i.e. it will show values from POST.

I need to retrieve values from the database and show these values in the same form when user modifies fields. One way to do this is to pass the values in the query string i.e.

href="add_form.php?modify=y&item_name=some_var"

$item_name = $_GET["item_name"];

<input type="text" name="item_name" value="<?PHP

if ($modify='y') {echo $item_name} else { echo $_POST['item_name'];} ?>" />

But in this case there will be a lot of variables in the url as many as there are fields in the form.

Can this be done another way, less bulky way?
 
Back
Top