Post multiple lines with PHP -
when presses submit button line added code:
<html> <head> </head> <body> <form method ="post" action="" name ="formpje"> line<input type="text" name="name"><br> <input type="submit" name="submit"><br> </form> <?php $post = $_post['name']; echo $post; ?> </body> </html>
the result:
when add new line current 1 gets changed newest one. want stay add new one. heres like:
try this, each time submit form place name session , print out bellow.
<?php session_start(); if( isset( $_post[ 'submit' ] ) ) { $_session[ 'submissions' ][] = $_post[ 'name' ]; } ?> <form method ="post" action="" name ="formpje"> line<input type="text" name="name"><br> <input type="submit" name="submit"><br> </form> <?php foreach( $_session[ 'submissions'] $line ) { echo $line."\n"; <------ may need replace "<br>" instead of "\n" html. } ?>
Comments
Post a Comment