PhpSnip.com

User Stats

On the fly multiple form entry creator

This script allows you create a multiple entry form on the fly. The end-user determines how many entries they want and the form is created accordingly.

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 155

Source Code ( 80 lines )

<!--
This is a free script - I hope it helps someone.

Keep Open Source Free!

This script allows you create a multiple entry form on the fly.
The end-user determines how many entries they want and the form
is created accordingly.

michael gbadebo
mailforever@yahoo.com
-->
<font size=3 color=red><b>go Create</b></font><hr><p>
<?php
$linenum = 1;
?>

<form method="post" action="<?php echo $ME; ?>">
How many name(s) 
<input type=text name=cell value="" size=2 max=2> do you want to register? 
<input type=hidden name=formname value="cellform" size=2 max=2>
<input type=submit value="go create!">
</form>

<form method="post" action="<?php echo $ME; ?>">
<input type=hidden name=formname value="inputform" size=2 max=2>
<input type=hidden name=passcell value="<?php echo $cell; ?>">
<table border=1>

<?php
if ($formname=="cellform"){
   if ($cell) {
?>

<tr>
<td><b>No</b</td><td><b>First Name</b></td><td><b>Last Name</b></td><td><b>Nick Name</b></td>
</tr>

<?php
   while ($linenum <= $cell){
   $line = "<tr>";
   $line .= "<td>$linenum</td><td><input type=text name="cella$linenum" value=""></td><td><input type=text name="cellb$linenum" value=""></td><td><input type=text name="cellc$linenum" value=""></td>";
   $line .= "</tr>";
   echo $line;
   $linenum = ++$linenum;   
   }
$cell = $passcell;
?>

<tr><td> </td><td colspan=3><input type=submit value="save my stuff!"></td></tr>

<?php
	 }
}
?>

</table>
</form>
<?php
if ($formname=="inputform"){
?>
<table border=1>
<tr>
<td><b>No</b</td><td><b>First Name</b></td><td><b>Last Name</b></td><td><b>Nick Name</b></td>
</tr>

<?php

   while ($linenum <= $passcell){

   $myumma="cella".$linenum;
   $myummb="cellb".$linenum;
   $myummc="cellc".$linenum;
   echo "<tr><td>$linenum</td><td>".$$myumma."</td><td>".$$myummb."</td><td>".$$myummc."</td></tr>";
   $linenum = ++$linenum;
   }
echo "<p>".$passcell." name(s) where saved";
?>
</table>
<?php } ?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise