I'm a bit new to php and am hoping that someone would be kind enough to help me with my problem. What I want to achieve is as follows: I created a form in my .php file, once I click the add button I want another form to appear on the same page but overwrite/delete the previous form. Here is what I need help with:

How can I output another form (on the same .php page) and overwrite/delete the previous form using php "without having to create another .php file"?

Here is my forms.php code:



<link rel="stylesheet" type="text/css" href="forms.css" />
<title>about forms</title>



<form action="" method="post" id="form1">
   <div id="container">
      <div id="header">About Forms</div>
      <div id="name">Name</div>
      <div id="nametext">
         &nbsp;&nbsp;<input type="text" name="nameEntry" size="30"></div>
      <div id="item"><br>Item Type</div>
      <div id="itemchoice">
         &nbsp;&nbsp;<input type="radio" name="itemtype" value="Book" checked>
         &nbsp;&nbsp;<input type="radio" name="itemtype" value="Author">
         &nbsp;&nbsp;<input type="radio" name="itemtype" value="Publisher">
      <div id="book"><b>Book Type</b> <font size="1px">(if applicable)</font></div>
      <div id="bookchoice"><select name="booktype">
                              <option value="Horror" selected><b>Horror</b>
                              <option value="Suspense"><b>Suspense</b>
                              <option value="Romance"><b>Romance</b>
      <div id="displaydebug">Display Debug</div>
      <div id="checkdebug">
         &nbsp;&nbsp;<input type="checkbox" name="debug">
         <font size="1px">Check if you want to display</font></div>
      <div id="buttons"><input type="submit" name="search" value="Search">
                        <input type="submit" name="add" value="Add">
   <div id="footer">Designed and Developed by me, Copyright 2011</div>		

   if (isset($_POST["add"])) {
      echo '<pre>';
      echo (print_r($_POST));
      echo '</pre>';		
   if (isset($_POST["search"])) {
      echo "Search button has not yet been implemented.";



Any help and suggestions would be appreciated. Thanks! =)

7 Years
Discussion Span
Last Post by diafol

You can use include files for the forms (pure php).
OR you can place both forms on the page and then toggle their visibility with js/css.

If you're creating a form wizard, there are loads of great jquery implementations. 'stepy' is one that I've used - looks good too. http://www.wbotelhos.com/stepy/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.