MasterACE14 Posted September 16, 2007 Share Posted September 16, 2007 How can I make a form like the following?: <form method="post" action="commentpage.php"> <textarea rows="5" cols="20" wrap="physical" name="comments"> Enter Comments Here </textarea> <input type="submit" value="submit"> </form> <?php echo "$_POST['comments'] was your comment"; ?> I just want to have a form that does everything on one page, instead of being sent to another page with "action="anotherpage.php"" Regards ACE Link to comment https://forums.phpfreaks.com/topic/69548-displaying-form-results-on-same-page/ Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 Then put the code at the top of page: if(isset(POST) { // Handle // Display } else { // Show form } Link to comment https://forums.phpfreaks.com/topic/69548-displaying-form-results-on-same-page/#findComment-349467 Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Author Share Posted September 16, 2007 I'm having no luck here, Basically, the form is used to search for elements or values in a 2 dimensional array. And then echo it if it has found it. heres the code: <?php // encyclopedia /* includes */ include '/home/ace/public_html/conflictingforces/weapons.php'; ?> <div id = "encyclopedia"> <center><b><u>Encyclopedia - Beta</u></b><br></center><br> <fieldset><legend>Search</legend> <?php if(isset($_POST)) { // Handle // Display echo 'Item is '.array_search($_POST["item"],$weapons); } else { // Show form ?> <form method="post" action="index.php?page=encyclopedia"> item: <input type="text" size="15" maxlength="60" name="item"> <input type="submit" value="Search"> </form> <?php } ?> </fieldset> <br> <center> <center> <?php /* Grab weapon Array and Display it */ for ($row = 0; $row < 3; $row++) { echo "<table class=\"fix\">"; echo "<tr><td colspan='2'>WEAPON</td></tr>"; foreach($weapons[$row] as $key => $value) { echo "<tr>"; echo "<td>".$key."</td>"; echo "<td>".$value."</td>"; echo "</tr>"; } } echo "</table>"; ?> </center> </center> </div> Regards ACE Link to comment https://forums.phpfreaks.com/topic/69548-displaying-form-results-on-same-page/#findComment-349478 Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Author Share Posted September 16, 2007 anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/69548-displaying-form-results-on-same-page/#findComment-349486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.