如何通过html/javascript表单输入在服务器上创建新的html页面 [英] How to create new html pages on a server via html/javascript form input

查看:85
本文介绍了如何通过html/javascript表单输入在服务器上创建新的html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用基本的html/javascript表单输入数据,然后单击提交"按钮时,结果是在Web服务器上创建了一个新的html文档.初始表单内容将用于确定在创建新html页面时将哪些数据添加到新的html页面.大概使用PHP/MySQL.谢谢.

I want to know if it is possible to use a basic html / javascript form to input data and then when the submit button is clicked the result is the creation of a new html document on the web server. The initial form contents would be used to determine what data is added to the new html page when it is created. Presumably using PHP/MySQL. Thanks.

推荐答案

JavaScript在客户端(而不是服务器)上运行,因此无法直接创建文件.这可以通过使用处理表单的服务器上的PHP脚本来完成.这与显示基于表单数据的页面非常相似,但是它会写入文件:

JavaScript runs on the client, not the server, so it can't create files directly. This would be done using a PHP script on the server that processes the form. It's very similar to displaying a page based on the form data, but instead it writes to a file:

$f = fopen($filename, 'w') or die "Can't create file $filename";
fprintf($f, "<html>\n<body>\n");
// and so on
fprintf($f, "</body>\n</html>\n");
fclose($f);

这篇关于如何通过html/javascript表单输入在服务器上创建新的html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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