tkdiamond08 Posted June 11, 2009 Share Posted June 11, 2009 Hey all, I'm pretty new to PHP, and I seem to be having trouble using multiple forms. I know there's probably a million other topics similar to this, but what i'm trying to accomplish isn't exactly common. Anyways what I need is 3 values taken from a form with 3 separate inputs (1 a file upload, 1 a text field for the video name, and 1 a drop down list of subjects) and to store them for later use in my script (called upload_php2.php) after the submit button is hit. It looks right on the site, however it doesn't function properly. I got them each working separately with their own submit button, however that is definitely not how I want it to work. Here's the php code that is on the upload page itself: session_start(); $subjects = array('','Math', 'Science', 'Tech', 'Social Science', 'English'); if(isset($_POST['submit']) && $_POST['videoname'] != null) { # If this form has been submitted and the name is not null $_SESSION['name'] = $_POST['videoname']; # Use what has been submitted } if(isset($_POST['submit']) && $_POST['subjs']!=0) { # If this form has been submitted and the subject array value (1,2,3..etc) is not 0 (which means they didn't select it) $_SESSION['subject'] = $subjects{$_POST['subjs']}; # Use what has been submitted } function showOptionsDrop($array, $active) { $string = ''; foreach($array as $k => $v){ if(is_array($active)) $s = (in_array($k, $active))? ' selected="selected"' : ''; else $s = ($active == $k)? ' selected="selected"' : ''; $string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n"; } return $string; } And here's the html code on the upload page: <form action="upload_file2.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <br /> <label for="file">Name your Video:</label> <input type="text" value="" name="videoname" /> <br /> <br /> Select a Subject: <select name="subjs"> <?php echo showOptionsDrop($subjects, $_SESSION['subject']); ?> </select> <br /> <br /> <input type="submit" name="submit" value="submit" /> </form> Any ideas? Thanks! Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/ Share on other sites More sharing options...
gijew Posted June 11, 2009 Share Posted June 11, 2009 Why can't all 3 fields be in one form? Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/#findComment-853925 Share on other sites More sharing options...
tkdiamond08 Posted June 11, 2009 Author Share Posted June 11, 2009 Why can't all 3 fields be in one form? Sorry that's what I meant, they are all in one form in my code. Edited above. Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/#findComment-853928 Share on other sites More sharing options...
tkdiamond08 Posted June 12, 2009 Author Share Posted June 12, 2009 bump Someone must know how to accomplish this!! Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/#findComment-854314 Share on other sites More sharing options...
tkdiamond08 Posted June 15, 2009 Author Share Posted June 15, 2009 I can't seem to find any help online , cmon guys this is for a school project which has to be done by early tomorrow!!! I need your expertise! Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/#findComment-855934 Share on other sites More sharing options...
haku Posted June 15, 2009 Share Posted June 15, 2009 Why don't you just set the action of the script as upload_php2.php? Link to comment https://forums.phpfreaks.com/topic/161852-multiple-forms-problems/#findComment-856035 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.