<?php { $name = $_POST['name']; { foreach($name as $value) { $_SESSION['value'] = $value; } } } ?> <html lang="pl"> <head> <link rel="stylesheet" href="css/style.css" type="text/css"> </head> <body> <div id="container"> <form method="post"> <?php for($i = 1; $i <= 3; $i++) { echo '<input type="text" name="name[]" placeholder="Imię i Nazwisko:" value='.$_SESSION['value'].'>'; } ?><br> <input type="submit" value="Zatwierdź" name="confirm"/> </form> </div> </body> </html>
Przerobiłem kod, ale wydaje mi się że nie jest on estetyczny. Proszę znawców o sugestię.
<?php { $_SESSION['name']= $_POST['name']; } ?> <html lang="pl"> <head> <link rel="stylesheet" href="css/style.css" type="text/css"> </head> <body> <div id="container"> <form method="post"> <?php for($i = 1; $i <= 4; $i++) { { ?> <input type="text" name="name[]" placeholder="Imię i Nazwisko:" value=""><?php }} { foreach($_SESSION['name'] as $value) { ?><input type="text" name="name[]" placeholder="Imię i Nazwisko:" value="<?php echo $value; ?>"><?php } } ?><br> <input type="submit" value="Zatwierdź" name="confirm"/> </form> </div> </body> </html>