Insert Html Code To A Page Via Php Script In Other Page March 03, 2024 Post a Comment i'm a little bit new for php so maybe this question is stupid. say i have a form: Solution 1: There are various ways of managing this, depending on your ultimate goal.You can just use separate files, and when user submits the form, it goes to the next page, ie. firstform.php -> SUBMIT goes to -> secondform.php, and so on. This way if you check their inputs and not what you like, you can send them back to the previous page/form with some error message to correct their choices.You can Use either GET as you are now, or POSTYou can use one page/file (say forms.php) and use PHP to determine what stage the user is at. Example - say you have user enter number of pictures they want, then ask for their details (may not be what you need but you get the flow idea) //FORM 1 - get number of picturesif ($_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 so ask for their detailselseif ($_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" />'; } CopyThis will let you start with FORM1, once submitted the GET info will return true for if is FORM1, and so it will show FORM 2, and so on for FORM 3, 4, 5, etc It's a crude way in some ways, and needs tweaking (ie testing if the submitted data is as you expect etc) but it gives you the idea on how to manage multiple forms on one page.Solution 2: As Filippo Toso said, you may include the HTML file in your code.php.Perhaps, if you don't want to have two files, you may make only one file and set the form to act like that:Baca JugaCompositing In Svg With D3Jquery Add Class To Object With .get() MethodUsing Angular2 Ngfor Index<formid="createNewGallery"name="newgallery"method="GET"action="./"><p><strong>please choose the number of pictures you want to upload: </strong><selectname="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><inputname="submitNumOfPictures"type="submit" /></form><?phpif (isset($_GET['numOfPictures'])){ $times = $_GET['numOfPictures']; for ($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" />'; } ?>Copy(note the "action" of the form)This is, maybe, pointless, compared to the previous solution but if you don't want to have two files you may do that in once, so that once you submit you will get the results right after your form without needing any other page!edit: forgot to mention that I suppose your file is named "index.php". If not, just replace the "./" with the correct address!Solution 3: try this <formid="createNewGallery"name="newgallery"method="post"action="code.php"><p><strong> please choose the number of pictures you want to upload: </strong><selectname="numOfPictures"id="numOfPictures"><optionvalue="3">3</option><optionvalue="4">4</option><optionvalue="5">5</option><optionvalue="6">6</option><optionvalue="7">7</option><optionvalue="8">8</option><optionvalue="9">9</option><optionvalue="10">10</option></select></p><inputname="submitNumOfPictures"type="submit" /></form>Copycode.php<?php$times = $_POST['numOfPictures']; echo$times; ?>Copy Share You may like these postsCreate A Php Dropdown Menu From A For Loop?How To Connect Phonegap Application To InternetPhp Preg_match Not Showing Brackets And Its Content In Result StringHtml Table With Inline Php Post a Comment for "Insert Html Code To A Page Via Php Script In Other Page"
Post a Comment for "Insert Html Code To A Page Via Php Script In Other Page"