insert html code to a page via php script in other page -


i'm little bit new php maybe question stupid.

say have form:

<form id="createnewgallery" name="newgallery" method="get" action="code.php"><p><strong>please choose number of pictures want upload:   </strong>   <select name="numofpictures" id="numofpictures">        <option>3</option>       <option>4</option>       <option>5</option>       <option>6</option>       <option>7</option>       <option>8</option>       <option>9</option>       <option>10</option>   </select></p>   <input name="submitnumofpictures" type="submit" /> </form> 

by submiting form want add afterwards form, know can in particular page want code not messy, want in page, code.php

and code:

<?php  if (isset($_get['numofpictures'])){      $times = $_get['numofpictures'];     ($i = 1; $i <= $times; $i++){         echo '<br />select picture number '.$i.': <br />';         echo '<input name="file'.$i.'" type="file" />';      }     echo '</br><input name="submitfiles" type="submit" />';  } 

the result im getting output in new page, code.php, want create form afterwards had on index php.

i required result if mt php coding in index page.

there various ways of managing this, depending on ultimate goal.

you can use separate files, , when user submits form, goes next page, ie. firstform.php -> submit goes -> secondform.php, , on. way if check inputs , not like, can send them previous page/form error message correct choices.

you can use either now, or post

you can use 1 page/file (say forms.php) , use php determine stage user at. example - have user enter number of pictures want, ask details (may not need flow idea)

//form 1 - number of pictures if ($_get['whichform'] == '')   {     echo '<form id="createnewgallery" name="newgallery" method="get"            action="'.$_server['php_self'].'"">';     echo '<input type="hidden" name="whichform" value="form1" />';     echo '<input name="submitnumofpictures" type="submit" />';   }  //form 2 - number of pictures submitted ask details elseif ($_get['whichform'] == 'form1')   {     echo '<form id="getuserdetails" name="userdetails" method="get"            action="'.$_server['php_self'].'"">';     echo '<input type="hidden" name="whichform" value="form2" />';     echo '<input name="userdetails" type="submit" />';   } 

this let start form1, once submitted info return true if form1, , show form 2, , on form 3, 4, 5, etc it's crude way in ways, , needs tweaking (ie testing if submitted data expect etc) gives idea on how manage multiple forms on 1 page.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -