0

我正在开发一个 HTML 页面项目,其中有 2 个文本框,基本上我想保存用户放入文本框中的输入数据。我们在我的 C# 类中所做的是将所有输入保存到 XML 文件中,所以我假设有类似的方法?到 XML 或其他可以存储文本的文件?

有谁知道解决办法吗?

4

1 回答 1

0

我推荐以下 php 脚本

   <?php
// check that form was submitted
//   (you'll need to change these indices to match your form field names)
if( !empty( $_POST['firstname'] ) && !empty( $_POST['lastname'] ) ){
    // remove html tags from submission
    //   (since you don't want them)
    $firstname = strip_tags( $_POST['firstname'] );
    $lastname = strip_tags( $_POST['lastname'] );
    // create the date
    //   (you can change the format as desired)
    $date = date( 'Y-m-d' );
    // create an array that holds your info
    $record = array( $firstname,$lastname,$date );
    // save the record to your .txt file (I still recommend JSON)
    $json = json_encode( $record );
    $file = '/_server_/path/to/yourfile.txt';
    file_put_contents( $json,$file );
}
于 2013-04-21T11:36:10.597 回答