rascle Posted January 3, 2011 Share Posted January 3, 2011 Hi I need to have 2 forms but one embedded in the other, the reason for this is that they both need to be Posts and I cant find another way to securely send information (other than GET which isnt secure). However I cant seem to get 2 forms embedded since one submit button just doesnt want to work! Is this possible? If not does anyone know of any other method of how I can securely send data without forms? What I want to do: <form name="sendimage" action="index.php" method="post"> <form name="editimage" action="edit.php" method="post"> <input type="hidden" name="send" value="imagename"><image src="blah"> <input type="submit" value="Send Image"> <input type="hidden" name="edit" value="imagevalue"><input type="submit" value="Submit"> </form> ^^ That is just an example of what I want to do! Thanks Rhys Quote Link to comment Share on other sites More sharing options...
trq Posted January 3, 2011 Share Posted January 3, 2011 Its not possible, nor does your reasoning make sense. Quote Link to comment Share on other sites More sharing options...
haku Posted January 4, 2011 Share Posted January 4, 2011 Seconded. Nested forms are invalid. Why don't you explain what it is you want to do and we can tell you how to do it properly. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted January 6, 2011 Share Posted January 6, 2011 You don't have to nest forms to have both forms use the secure post method. You can create two or possibly hundreds of form on a webpage. Quote Link to comment Share on other sites More sharing options...
rascle Posted January 6, 2011 Author Share Posted January 6, 2011 You don't have to nest forms to have both forms use the secure post method. You can create two or possibly hundreds of form on a webpage. I know but basically I have a table being displayed using a while loop (in php, but this question is more about the HTML of it) and in the while loop I require a post form so that if the users click on the button it will send them to a viewuserpage, in the same while loop I require another postform so that I can have a multi tick box selection, so they can select the tick boxs and then select an option below, this all works except when you click on the link it doesnt do anything (obviously because they are nested) here is the code: (some of it is in PHP but that works it is just the HTML and form bits I am having trouble with) <?php echo' <table border="1"> <tr> <td> <font size="5">Check</font> </td> <td> <font size="5">Status</font></td> <td><font size="5">From</font></td> <td width="500"><font size="5">Subject</font></td> <td><font size="5">Date Sent</font></td> <td><font size="5">Time Sent</font></td> <td><font size="5">Action</font></td> </tr> <form action="rmail.php" method="post"> '; while($email = mysql_fetch_array($getemail)){ $id = $email['id']; if($email['status'] == "unread"){ echo "<tr bgcolor='#666666'>"; }else{ echo "<tr>"; } $checked = ($email['id']==1) ? 'checked="checked"' : ''; echo '<td><input type="checkbox" name="rmailmulti[]" value="'.$email['id'].'" '.$checked.' class="check" /></td>'; echo '<td>'; if($email['status'] == "unread"){ echo '<center><img src="/webimages/unread.gif" alt="Message Unread" width="30" height="25"></center>'; }else if($email['status'] == "read"){ echo '<center><img src="/webimages/read.gif" alt="Message Read" width="30" height="25"><center>'; } echo '</td>'; echo '<td>'.$email['from'].'</td>'; echo '<td><a href="rmail.php?viewmail&id='.$email['id'].'">'.$email['subject'].'</a></td>'; echo '<td>'.$email['date'].'</td>'; echo '<td>'.$email['time'].'</td>'; echo '<td><a href="index.php"><input type="image" src="/webimages/delete.png" onclick="return confirm(\'Are you sure you want to Delete?Click Ok to proceed and Delete or Cancel if you do not want to delete!\');" name="delete" value="'.$email['id'].'"></a><a href="viewmembers.php?user='.$email['from'].'"><img src="/webimages/eye3.gif" border="0" height="25" width="30"></a></td>'; echo "</font></tr>"; } echo "<tr><td><input type='submit' value='MULTI' class='submit'/></form> </td></tr></table>"; }?> Any Ideas? Thanks Rhys Quote Link to comment Share on other sites More sharing options...
haku Posted January 6, 2011 Share Posted January 6, 2011 Move your form tags outside of your loop. This will prevent them from being outputted more than once. Quote Link to comment Share on other sites More sharing options...
rascle Posted January 6, 2011 Author Share Posted January 6, 2011 ?? The first form tag is out of the loop,and I how would I move the second one without affecting/breaking the loop? Quote Link to comment Share on other sites More sharing options...
haku Posted January 7, 2011 Share Posted January 7, 2011 Show us the HTML output of your script. We can then show you what the proper HTML should look like, after which you can adjust your PHP script to output that. Quote Link to comment Share on other sites More sharing options...
rascle Posted January 7, 2011 Author Share Posted January 7, 2011 Its not the PHP that is wrong it is the location of the forms which are wrong. Basically it gets info from a MySQL table and outputs in a table, the tickbox, the Name of the Message, and then the options (the form if you want to delete it). It also includes the submit box and the bottom/ end of the table. I have set up a test run of the code (http://www.rasclerhys.com/test.php) the code for that page is: <?php echo'<html><head>'; $pagename = "TEST"; include "banner.php"; include "headinfo.php"; $updated = FALSE; if(isset($_POST['admin'])){ $admin = $_POST['admin']; array_map('intval',$admin); $admin = implode(',',$admin); echo $admin; $updated=TRUE; } echo'</head><body>'; echo'<form action="test.php" method="post">'; if($updated===TRUE){ echo '<div>Privileges Updated!</div>'; } echo'<table> <tr> <th>Username</th> <th>Admin Privileges</th> </tr>'; $result = mysql_query("SElECT `id`,`subject`,`to` FROM `rmail` ORDER BY id ASC"); while(list($id,$subject,$to)= mysql_fetch_row($result)){ $checked = ($to==1) ? 'checked="checked"' : ''; echo '<tr><td>'.$subject.'</td><td><input type="checkbox" name="admin[]" value="'.$id.'" '.$checked.'/></td>'."\n"; echo '<td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr>'; } echo'<tr><td colspan="2"><input type="submit" name="submit" value="Update Privileges" /></form></td></tr> </table>'; echo'</body></html>'; ?> Basically if you click delete nothing happens (because I havent done the code for that yet) however if you select the tickboxes and click submit nothing happens, because of the form nesting, so how would I change the code for it to work? Thanks Rhys Quote Link to comment Share on other sites More sharing options...
haku Posted January 7, 2011 Share Posted January 7, 2011 If the location of the forms are wrong, and the php is outputting the forms, then the php is wrong. Again, show us your HTML output, and we can tell you how it should look. You can then adjust your PHP to output that HTML. Quote Link to comment Share on other sites More sharing options...
rascle Posted January 8, 2011 Author Share Posted January 8, 2011 Ok but there are no error outputs by the page. The HTML output code is: <html><head><!-- GET BROWSER TYPE --> <!-- END OF GET BROWSER TYPE --> <!-- BANNER TAG --> <center><div id="banner"><div id="right"><a href="index.php" onMouseover="fixedtooltip('View the Homepage.', this, event, '200px')" onMouseout="delayhidetip()"><img src="/webimages/home.gif" border="0"></a><a href="games.php"onMouseover="fixedtooltip('View the Games Page.', this, event, '200px')" onMouseout="delayhidetip()"><img src="/webimages/games.gif" border="0"></a><a href="forums.php" onMouseover="fixedtooltip('View the Forums.', this, event, '200px')" onMouseout="delayhidetip()"><img src="/webimages/forums.gif" border="0"></a></div></div><div id="box"><h1>RascleRhys.com </h1>TEST</div></center><!-- NO JAVASCRIPT TAG --> <center><div id="noscript"><img src="http://www.rasclerhys.com/webimages/warning.gif"> RascleRhys.com recommends that you view the site with Internet Explorer. Click <a href="ie.php" style="color: black;">here</a> for more info.</div></center> <!-- END OF NO JAVASCRIPT TAG --> <!-- END OF BANNER TAG --> <!-- DB CONNECT --> <!-- END OF DB CONNECT --> <html> <head> <title>RascleRhys.com - TEST - Free Online Games </title> <!-- META CODE --> <meta name="description" content="Free Online Games including Action,Arcade,Puzzle,Racing and Sport." /> <meta name="keywords" content="Games, Flash games,online games,forum,action,arcade,puzzle,racing,sport,action games,arcade games, racing games, puzzle games, sport games" /> <!-- END OF META CODE TAG --> <!-- EXTERNAL JAVASCRIPT LINKS --> <script type="text/javascript" src="/js/moreinfo.js"></script> <script type="text/javascript" src="/js/changelogin.js"></script> <script type="text/javascript" src="/js/hoveroverinfo.js"></script> <!-- END OF EXTERNAL JAVASCRIPT LINKS TAG --> <!-- FAVICON LINK --> <link rel="shortcut icon" href="/webimages/favicon.ico "> <!-- END OF FAVICON LINK --> <!-- STYLE SHEET --> <link rel="stylesheet" type="text/css" href="darkthemelayout.css" /> <!-- END OF STYLE SHEET TAG --> <!--COPY TO CLIPBOARD TAG --> <script language="JavaScript"> function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("RemoveFormat"); Copied.execCommand("Copy"); } </script> <!-- END OF COPY TO CLIPBOARD TAG --> <!-- HIDE PATIENT TEXT TAG --> <script type="text/javascript"> function complete(){ document.getElementById("warning").style.display="none"; } </script> <!-- END OF HIDE PATIENT TEXT TAG --> <!-- GET USER INFO --> <!-- DB CONNECT --> <!-- END OF DB CONNECT --> <!-- CODE FOR THE USER LOGGED FUNCTION; FIRST IF THE USER IS LOGGED IN CREATE A TIME FOR 20 MINUTES SAYING THE USER IS LOGGED IN FOR THAT TIME, IF THEY CONTINUE TO STAY ON THE SITE FOR THIS TIME, IT WILL UPDATE THE TIME. IF THEY ARE NOT THEN THE TIME WILL REMAIN. WHEN ANYONE GOES ON THE SITE THEY WILL CHECK TO SEE IF THE TIME FOR ANY USER HAS EXPIRED. IF IT HAS THEN IT WILL BE RESET AND THEY WILL BE CONSIDERED OFFLINE. --> <!--END OF USER LOGGED FUNCTION --> <!-- END OF USER INFO TAG --> </head> </html></head><body><form action="test.php" method="post"><table> <tr> <th>Username</th> <th>Admin Privileges</th> </tr><tr><td>TEST</td><td><input type="checkbox" name="admin[]" value="20" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>TEST</td><td><input type="checkbox" name="admin[]" value="22" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Admin Warning</td><td><input type="checkbox" name="admin[]" value="26" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Admin Warning</td><td><input type="checkbox" name="admin[]" value="27" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Admin Warning</td><td><input type="checkbox" name="admin[]" value="28" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Smileys</td><td><input type="checkbox" name="admin[]" value="29" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Bovered</td><td><input type="checkbox" name="admin[]" value="38" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Re: Whoop Reply Works!</td><td><input type="checkbox" name="admin[]" value="39" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td>Re: DOUBLE WHAMMY!</td><td><input type="checkbox" name="admin[]" value="40" /></td> <td><form name="delete" action="delete.html" method="post"><input type="submit" value="Delete"> </form> </td></tr><tr><td colspan="2"><input type="submit" name="submit" value="Update Privileges" /></form></td></tr> </table></body></html> Which can be viewed at http://rasclerhys.com/test.php Thanks Rhys Quote Link to comment 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.