HTML表单发布在PHP页面上 [英] HTML Form to post on php page

查看:102
本文介绍了HTML表单发布在PHP页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您的阅读。我正在尝试创建一个HTML表单,以便我的朋友可以在其中键入文本,然后用任何输入到表单中的内容更新他的网站。我试图创建一个HTML表单(在一个PHP页面上),它将任何在它的textarea中输入的内容发布到home.php文件中。然而,我不是简单地做一个一次性的帖子,而是试图让它在textarea中输入的内容保存到home.php文件中。 home.php文件是空白的,我创建的表单如下:

Thank you for reading. I'm trying to create a HTML form so that my friend can type text into it and thereafter, updates his web site with whatever is typed into the form. I'm trying to create a HTML form (on a php page) which posts whatever is entered within it's textarea to the home.php file. However, rather than simply do a "one-off" post, I'm trying to make it so that whatever is entered within the textarea saves the data into the home.php file. The home.php file is blank, and the form which I have created is as below:

<form method="post" action="home.php">
    <textarea id="element" name="element" rows="15" cols="80" style="width: 80%">
    </textarea>
    <input type="submit" name="save" value="Save" />
    <input type="reset" name="reset" value="Reset" />
</form>

例如,如果单词example被输入到提交的表单中,那么home.php文件应该写上example字样。

For example, if the words "example" was typed into the form then submitted, the home.php file should have the words "example" written on it.

如果您需要更多详细信息,请回复。谢谢。 :)

If you require more details, then please reply. Thank you. :)

推荐答案

<?php

 $Input = $_POST['element'];

 $FileToUpdate = "home.php";
 $fh = fopen($FileToUpdate , 'w') or die("can't open file");

 fwrite($fh, $Input);

 fclose($fh);     

 ?>

上面的代码将完成你所希望的操作,但会覆盖页面(要追加 this reference )。但实际上我认为您需要从基础知识入手,并具有良好的 PHP教程。

The code above will do what you wish, but will overwrite the page (to append see this reference). But really I think you need to start from basics with a good PHP Tutorial.

这篇关于HTML表单发布在PHP页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆