日期:2014-05-17  浏览次数:20419 次

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


<html>
<head>
<title>control</title>
</head>
<body>
<form id="back">
<div align=center>
titleinput type=text name=title id=title maxlength=30 >
belong<select name=belong id=belong>
<option>overseas
<option selected>internal  
</select>
<br>
</div>
<br><br>
body<br>
<textarea wrap=head name=comment id=comment rows=20 cols=100> </textarea><P>
<input type=submit value=submit onclick="submit1($title,$belong,$comment);"><input type=reset value=reset>
</form>
</body>
</html>

这段程序是我在下面的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呀


<?php
if($_GET){
file_put_contents('news1.php',$_GET['title'],$_GET['belong'],$_GET['comment']);
}
?>
------解决方案--------------------
最直接的一个原因,你用客户端事件(onclick)来调用服务器端的函数(submit1($title,$belong,$comment))。
this is impossble mission!