html表单编辑php代码

发布于 2024-12-06 05:24:25 字数 670 浏览 0 评论 0原文

我正在开发一个允许用户在 PHP 文件中编辑 PHP 代码的项目。

我有一个PHP页面,使用邮件功能发送电子邮件。我想允许用户更改发送的消息(在邮件功能中)。

我知道如何重写文件,但如何编辑它,我不确定...

所以这是邮件功能:

$name=$_POST['userName'];

$emaily=$_POST['userEmail'];

$email = "$sponsor_email"; 


$subject = "the subject"; 


$message = "This is the message I want the user to be able to edit."; 

mail($email, $subject, $message, "From: $user-email"); 

现在我已经将 $message var 打印出来了html 表单(这样用户可以看到将要更改的内容,但我不知道如何实际编写代码以从提交中更改它。

有什么想法吗?

谢谢!

对不起大家......

我没有解释正常情况下,

带有邮件功能的php文件不会。用于从该表单发送电子邮件。我希望表单所做的就是编辑 php 文件,我不想用此表单发送电子邮件,这是为了让用户编辑邮件功能。 ...

I'm working on a project that allows users to edit PHP code in PHP file.

I have a PHP page that uses the mail function to send emails. I want to allow the user to change the message sent out (in the mail function).

I know how to re-write over a file but how to edit it, I'm not sure...

So here's the mail function:

$name=$_POST['userName'];

$emaily=$_POST['userEmail'];

$email = "$sponsor_email"; 


$subject = "the subject"; 


$message = "This is the message I want the user to be able to edit."; 

mail($email, $subject, $message, "From: $user-email"); 

Now I've got the $message var printed out on in the html form (so the users can see what will be changed but i don't know how I'd go about actually writing the code to change it on from submit.

Any ideas?

Thanks!

Sorry guys....

I didnt explain the situation properly.

The php file with the mail function will not be used to send an email from that form. All i want the form to do is edit the php file basically. I don't want to send the email with this form, this is for users to edit the mail function. Hope thats more clear...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

似最初 2024-12-13 05:24:25

在您的编辑页面上,只需执行如下操作:

$message = file_get_contents("path to message file");
echo "<textarea id=\"message\">".$message."</textarea>";

然后您可以编辑文件的任何内容。

如果您使用数据库并清理用户输入,而不是将所有内容保存到文件中,可能会更好。

On your editing page, just do something like below:

$message = file_get_contents("path to message file");
echo "<textarea id=\"message\">".$message."</textarea>";

Then you can edit whatever the contents of the file were.

Might be better though if you used a database, and sanitized the user input - rather than saving everything to a file.

厌味 2024-12-13 05:24:25

将文本区域放入名为“message”的表单中,然后执行 $message = $_POST['message'];

Put the textarea in the form named "message", then do $message = $_POST['message'];

少女净妖师 2024-12-13 05:24:25

创建一个 PHP 来读取包含要编辑的代码的 PHP 文件中的内容,然后将其打印在 HTML 文本区域中,然后创建另一个文件,将修改后的代码写入具有代码(要修改)的 PHP 文件中。您可以使用谷歌查找如何在文件中读写。

create a PHP that read what is in the PHP file that contains code to be edited then print it out in a HTML textarea then make another file that will write that modified code in the PHP file that has the code(to be modified). You can use google find how to read and write in a file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文