Get And Echo Inputs From Textarea Repeatedly December 26, 2023 Post a Comment I have a simple HTML form like this: Solution 1: If you don't want to put the values in a database you could use a sessionsession_start();at the very top of your page and <?phpif( $_SESSION['counter'] > 0 ) $_SESSION['texts'] = $_SESSION['texts'] . "<br />Question " . $_SESSION['counter'] . ": Something " . $_POST['question']; $_SESSION['counter']++; ?><?phpecho$_SESSION['texts']; // put this in a div where you want to see them ?>CopyThis will only clear when the browser is shut.This is a very crude outline but you could look at tutorials on sessions and how to use them.Baca JugaReplace Div Inside Another Div With Textarea, Edit Text And Replace BackDisplay Textarea Output As A List With BulletsSet Max Characters In Textarea Base On Textarea Height And WidthYou would also need a counter at the bottom of your script to add in the number. $_SESSION['counter']++; CopyUsing hidden inputs to replace sessions without array or for loop.<?php$counter = $counter + (int) $_POST['counter']; // (int) helps sanitise this by forcing type change to integer - any text would be converted to 0//echo $counter; // for trackng$texts = $_POST['texts']; // MUST be sanitized and escaped for mysqliif($counter > 0) $texts = $texts . "<br />Question " . $counter . ": Something " . $_POST['question']; $counter++; ?><formaction="<?phpecho$_SERVER['PHP_SELF']; ?>"method="post"><textareaid="question"name="question"></textarea><inputtype="hidden"name="texts"id="texts"value="<?phpecho$texts;?>" /><inputtype="hidden"name="counter"id="counter"value="<?phpecho$counter; ?>" /><inputtype="submit"/></form><?phpecho$texts; // put this in a div where you want to see them ?>CopyDo not use this code without cleaning up the post variables or you will get hacked to bits by hackers. See other posts on preg_replace() and on php.net Share You may like these postsEliminate Render-blocking Javascript And CssSet The Source Of Adobe Pdf Browser Plugin To Be A Byte Stream?Does Ie8 Support Html5 And Css3?Html Agility Pack C# Paragraph Parsing Problem Post a Comment for "Get And Echo Inputs From Textarea Repeatedly"
Post a Comment for "Get And Echo Inputs From Textarea Repeatedly"