justAnoob Posted May 12, 2009 Share Posted May 12, 2009 i have a form with a script inside it that has an action... within that script,, I echo another form with a different action... Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/ Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Sure. Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832182 Share on other sites More sharing options...
justAnoob Posted May 12, 2009 Author Share Posted May 12, 2009 I thought it was because it use to work(the setup that I have). But now it will not.... What is the trick for nesting a form inside a form??? When I run the script inside form22,,, the action from form2 runs instead. Here is the form(s) setup. <form id="form2" name="form2" method="post" action="updatepic.php"> <?php session_start(); include "connection.php"; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit' LIMIT 1"); $e_row = mysql_fetch_assoc($result); $query = mysql_query("SELECT count(*) FROM abcxyz WHERE user_id = " . $e_row['id']) or die(mysql_error()); $query_data = mysql_fetch_row($query); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) { $pageno = $lastpage; } if ($pageno < 1) { $pageno = 1; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " $limit"); if($lastpage != 0) { echo "<table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td width='188' height='180'><div align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; if(empty($row['imgpath2'])) { echo '<form action="postnewitem.php" method="post" enctype="multipart/form-data" name="form22"> <div align="center"> <input name="image" type="file" id="image" size="15" input="input" /> <br> <input name="submit" type="submit" value="Upload Picture 2" id="submit" /> </div> </form>'; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath3'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath4'] . '" width="125" alt="" />'; echo "</div></td><td width='190'><div align='center'>"; echo '<img src="' . $row['imgpath5'] . '" width="125" alt="" />'; echo "</div></td></tr><tr><td height='43' colspan='4'>"; echo '<strong>Item Name:</strong> <input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" /> '; if ($pageno == 1) { echo " Previous Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'> Previous Item </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next Item </a>"; } echo "</td><td><div align='center'>"; echo '<input type="hidden" name="id" value="' . $row['id'] . '" size="25" />'; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> <textarea name="description" cols="75" rows="5">' . $row['description'] . '</textarea>'; echo "</td><td><div align='center'>"; echo '<input type="submit" name="updatesubmit" id="updatesubmit" value="Update Item"><br><br><input type="submit" name="delete" id="delete" value="Delete Item ">'; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5">' . $row['in_return'] . ' </textarea>'; echo "</td><td><div align='center'>"; if(isset($_SESSION['updatecomplete'])) { unset($_SESSION['updateerror']); echo $_SESSION['updatecomplete']; } if(isset($_SESSION['updateerror'])) { unset($_SESSION['updatecomplete']); echo $_SESSION['updateerror']; } //echo ''; echo "</div></td></tr><tr><td colspan='4'>"; echo '<input type="hidden" name="id" value="' . $row['category'] . '" size="25" />'; echo "</td><td><div align='center'>"; echo ''; echo "</td></tr>"; } echo "</table>"; } else { echo "You currently have no pics."; } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832802 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 I don't think you can nest forms.... Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832808 Share on other sites More sharing options...
justAnoob Posted May 12, 2009 Author Share Posted May 12, 2009 I hope somebody chimes in saying that they have.. I really don't want to setup my page again. Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832809 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 I hope somebody chimes in saying that they have.. I really don't want to setup my page again. No seriously, I don't think you can....i've been proven wrong many time though!!!! Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832811 Share on other sites More sharing options...
PFMaBiSmAd Posted May 12, 2009 Share Posted May 12, 2009 Nested forms are invalid HTML and DON'T work. You either need to make one form that includes all the fields or multiple separate (non-nested) forms. Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832812 Share on other sites More sharing options...
MadTechie Posted May 13, 2009 Share Posted May 13, 2009 its a no from me as well.. sorry! Can't you just include "postnewitem.php" in the updatepic.php script and remove the <form action="postnewitem.php" method="post" enctype="multipart/form-data" name="form22"> and next </form> ? Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832882 Share on other sites More sharing options...
justAnoob Posted May 13, 2009 Author Share Posted May 13, 2009 I don't know,, can you... I still learning a lot... But I think tomorrow I will just redo my page with all the forms separated.. Which sucks.. But oh well. Quote Link to comment https://forums.phpfreaks.com/topic/157776-form-inside-a-form/#findComment-832935 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.