gpt4 book ai didi

PHP(编辑和删除 html 文件)

转载 作者:行者123 更新时间:2023-11-28 01:00:43 28 4
gpt4 key购买 nike

<分区>

我在学校学到的是使用file_put_content()输入和显示数据。但是我不知道如何编辑/更新或删除里面的数据。

我的“form.php”

    <!--Form to the php script-->

<form action="foodscript.php"method="post">
I love:<br>
<input type="text" name="foodname" value="">
<input type="submit" value="Submit">
</form>

在我输入一些食物名称后,它被发送到文件 call "foodscript.php"

<?php
//This is where my input data is being process to the txt file.
$name= $_POST['foodname'];

//This is where my data would be store in this file.
$file= "foodhistory.html";

//The function is begins to created new file and store my data on it.
file_put_contents($file, $name . PHP_EOL, FILE_APPEND);

?>

然后,foodhistory.html 已创建并存储我已在表单中输入的数据。数据在 foodhistory.html 中调用 “Sushi”

所以我的问题是如何使用带有删除和编辑按钮的新表单来编辑/更新或删除我的数据“Sushi”?如果你们有更好的想法如何去做,你介意告诉我过程或方法吗?我只是个学生。

非常感谢。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com