dongyun9120 2014-07-22 16:43
浏览 19

如何使用PHP从表单创建列表?

I'm looking to use a form to make updating a list on a website quick and simple. Currently I have standard form that just prints out the contents added onto another page, but what I want is to be able to constantly update the page using the form. For example if I use the form to enter my name as John Smith, it will output John Smith, but If I want to add a friends name later, I want it to add their name to the list:

Mike Jones
John Smith

Here is the sample form

 <html> 
   <head><title>Test Page</title></head> 
   <body> 
     <h2>Data Collection</h2><p> 
     <form action="Test2.php" method="post"> 
     <table> 
       <tr><td>Name:</td><td><input type="text" name="Name" /></td></tr> 
       <tr><td>Age:</td><td><input type="text" name="Age" /></td></tr> 
       <tr><td colspan="2" align="center"><input type="submit" /></td></tr> 
     </table> 
     </form> 
    </body> 
 </html> 

And here is the output.

<html>
  <head>
  </head>
    <body>

       <?php 

          print "Your name is ". $Name; 
          print "<br />"; 
          print "You are ". $Age . " years old"; 
          print "<br />"; 

        ?> 
      </body>
    </html>

I was thinking that there needs to be some sort of loops/counter that checks to see if new content was added, but I'm not sure how to go about that.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀