tags:

views:

40

answers:

2

I'm a php newbie and im making a small video upload site (very fun :). Anyway How would I do to keep the form inputs for the next part, where you select a file to upload.

<form action="upload.php" method="post">
<input type="hidden" name="action" value="step2">

Title: <input type="text" size="50" maxlength="50" value="" name="title" />
Description: <textarea name="description" style="width:278px; height:70px;"></textarea>
Tags: <input type="text" size="50" maxlength="100" value="" name="tags" />
<input type="submit" value="Next &gt;" />

</form>

And when you press "Next" I want it to take the form values to the next form.

When you press next:

if ($_POST['action'] == 'step2') {
echo '<form action="upload.php" method="post" enctype="multipart/form-data">';
echo 'Chose file: <input type="file" name="userfile" />';
echo '</form>';
// insert everything to table 'videos' title, description on so on that i entered from last form
return false;
}
+1  A: 

The simplest way is to reproduce form fields from the first page to the second page as hidden form fields.

Marcelo Cantos
A: 

As Marcelo stated: you could store stuff in hidden fields. Unfortunately that means you need to continually check that that data in the hidden fields is still valid (ie. that noone changed it in the hidden field).

At times like this, use sessions: store the data posted from each page in the session, then reference it when needed...

Narcissus