ユーザーが最初のテキストフィールドに名前を挿入し、2番目のテキストフィールドに何かを書く必要があるフォームを作成しました1(ある情報)。これまでのところは良いテキストボックスの内容を取得し、そこから.txtファイルを作成してデータベースに保存します
echo "<form method='post' action='insert.php?selected=$openFolder&id=$student'>
Information name:</br> <input name='infoName' type='text' /><br />
Information:<br />
<textarea name='text' rows='15' cols='60'>
</textarea><br />
<input type='submit' name='submit' value='Submit Information'/>
</form>";
: はここに私のフォームのための私のコードです。
は今すぐフォームが送信されたときに私は、ファイルを作成する必要があります。
ファイル名を - >ユーザーが「infoName」テキストフィールド
を中に挿入され、その後、コンテンツを挿入することを名前'text'テキストフィールドの値をこのファイルに追加し、ファイル全体をデータベースに保存します。ここで
はそのために私のコードです:
if (isset($_POST['submit']))
{
//Make sure that a file name is given by the user
if (!$_POST['infoName'])
{
echo "<center><font color='red'>You must complete the Information name field</font></center>";
}
else
{
$informationName = $_POST['infoName'];
$informationContent = $_POST['text'];
$newFile = fopen($informationName,"w");
$content = fwrite($newFile,$informationContent . "\n");
$content = addslashes($content);
fclose($newFile);
$theSize = filesize($informationName);
if(!get_magic_quotes_gpc())
{
$informationName = addslashes($informationName);
}
$query = "INSERT INTO $openFolder (studentID, name, size, type, content, insertedBy) ".
"VALUES ('$student','$informationName', '$theSize', 'txt', '$content', '$username')";
mysql_query($query) or die('Error, query failed');
}
}
私の問題:
1)ファイルを右に作成され、私のデータベースではなく、それではない適切なコンテンツを格納しています。何らかの理由でファイルにテキストを正しく挿入していません...
2)データベースに保存されているファイルを除いて、2つのファイルがディレクトリに作成されています。
お願いします。私のコードを自由に変更してください! 私が間違っていることを教えてください!