Home  >  Article  >  Backend Development  >  简单的PHP程序有关问题2

简单的PHP程序有关问题2

WBOY
WBOYOriginal
2016-06-13 10:03:10969browse

简单的PHP程序问题2
小弟不才,问的都是简单的,以后还会有很多系列的小问题出来。
function submit1($title,$belong,$comment){
$fp= fopen("news1.php","rw");
fwrite($fp,$getphp($name,$commment));
}
?>




control




titleinput type=text name=title id=title maxlength=30 >
belong






body







这段程序是我在下面的HTML程序中生成了一个文本区域,通过提交按钮,生成了个PHP文件,把文本区域内的东西真到PHP文件中去(包括文章的标题和内容)。
ques1:但我点了submit后,没发现有生成的PHP文件.
ques2:我如何把填到文本区的内容写到PHP文件中去,且生成一个页面。我像让我写的文章的标题成为我的PHP文件的文件名,不知可不可以。
ques3:我看人家的文本内容都是在一个像word的写字板中,我调用什么函数也能后成

------解决方案--------------------
q3:ewebeditor
------解决方案--------------------
ji
------解决方案--------------------
$getphp($name,$commment)
onclick="submit1($title,$belong,$comment);"
你想干什么呢???
------解决方案--------------------
最好不要使用這種方法,這種"偷懶"的方式是不被PHP鼓勵的。

獲得變量用 $_POST 或 $_GET

還有 onclick="submit1($title,$belong,$comment);" 都出來了,你以為是JavaScript呀


if($_GET){
file_put_contents('news1.php',$_GET['title'],$_GET['belong'],$_GET['comment']);
}
?>
------解决方案--------------------
最直接的一个原因,你用客户端事件(onclick)来调用服务器端的函数(submit1($title,$belong,$comment))。
this is impossble mission!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn