当有人按下提交按钮时,会添加一行代码:
<html>
<head>
</head>
<body>
<form method ="POST" action="" name ="formpje">
A line<input type="text" name="name"><br>
<input type="submit" name="submit"><br>
</form>
<?php
$post = $_POST['name'];
echo $post;
?>
</body>
</html>
结果:
答案 0 :(得分:4)
试试这个,每次提交表单时,它都会将名称放入会话中并将其打印出来。
<?php
session_start();
if( isset( $_POST[ 'submit' ] ) )
{
$_SESSION[ 'submissions' ][] = $_POST[ 'name' ];
}
?>
<form method ="POST" action="" name ="formpje">
A line<input type="text" name="name"><br>
<input type="submit" name="submit"><br>
</form>
<?php
foreach( $_SESSION[ 'submissions'] as $line )
{
echo $line."\n"; <------ May need to replace this with "<br>" instead of "\n" for the html.
}
?>