Nieuw lid |
|
hey,
ik weet niet of wat ik hier heb zelfs een artikelsysteempje genoemd mag worden. maar ik heb een form gemaakt die een bestand zou moeten aanmaken met de ingevoerde gegevens. deze gegevens zijn (1) de naam van het bestand (2) de titel van eht artikel (3) de schrijver (4) de email van de schrijver (5) de tekst en (6) de datum, bewust handmatig in te voeren.
maar helaas doet het script niks en ik krijg een foutmelding: op regel 10. bij het stukje // $file = fopen("$_POST['title_bestand']", "a+"); //.
zou iemand mij kunnen vertellen of hetgeen wat ik doe wel goed is en misschien de fout aanwijzen?
hier de code:
<html>
<head>
<title>make article file</title>
</head>
<body>
<?php
unset($_POST);
if (!empty($_POST)) {
$file = fopen("$_POST['title_bestand']", "a+");
$start_html = "<html><head><title>".$_POST['title']."</title></head><body>";
$title_of_article = "<p style='font-family:arial; font-size:18pt; text-align:center;'>".$_POST['title']."</p>";
$writer = "<p style='font-family:arial; font-size:12pt; font-weight:bold; text-align:center;'>".$_POST['author']."<br>".$_POST['email']."</p>";
$text_of_article = "<p style='font-family:arial; font-size:13pt; text-align:justify;'>".$_POST['text']."</p>";
$date_of_publish = "<p style='font-family:arial; font-size:9pt; color:grey; text-align:right;'>".$_POST['date']."</p>";
if($file) {
$content = array(
"start_html" => $start_html;
"title_of_article" => $title_of_article;
"writer" => $writer;
"text_oa" => $text_of_article;
"date_op" => $date_of_publish;);
fwrite($file, $content);
fclose($file);
}
else {
echo ("The file can not be made!");
}
}else{
?>
<h2>Creating an article file</h2>
<form name="make_file_form" method="post" action="<?php echo($_SERVER["PHP_SELF"]); ?>">
Title of document: <input name="title_bestand" type="text"><br>
Title of article: <input name="title" type="text"><br>
Author of article: <input name="author" type="text"><br>
E-mail of author: <input name="email" type="text"><br>
Date of publication: <input name="date" type="text"><br>
Text of article: <textarea name="text" cols="40" rows="30"></textarea><br>
<input type="submit" name="submit" value="Send article"><input type="reset" name="reset" value="Reset form">
</form>
<?php } ?>
</body>
</html>
<html> <head> <title>make article file</title> </head> <body> <?php $file = fopen("$_POST['title_bestand']", "a+"); $start_html = "<html><head><title>".$_POST['title']."</title></head><body>"; $title_of_article = "<p style='font-family:arial; font-size:18pt; text-align:center;'>".$_POST['title']."</p>"; $writer = "<p style='font-family:arial; font-size:12pt; font-weight:bold; text-align:center;'>".$_POST['author']."<br>".$_POST['email']."</p>"; $text_of_article = "<p style='font-family:arial; font-size:13pt; text-align:justify;'>".$_POST['text']."</p>"; $date_of_publish = "<p style='font-family:arial; font-size:9pt; color:grey; text-align:right;'>".$_POST['date']."</p>"; if($file) { "start_html" => $start_html; "title_of_article" => $title_of_article; "writer" => $writer; "text_oa" => $text_of_article; "date_op" => $date_of_publish;); } else { echo ("The file can not be made!"); } }else{ ?> <h2>Creating an article file</h2> <form name="make_file_form" method="post" action=" <?php echo($_SERVER["PHP_SELF"]); ?>"> Title of document: <input name="title_bestand" type="text"><br> Title of article: <input name="title" type="text"><br> Author of article: <input name="author" type="text"><br> E-mail of author: <input name="email" type="text"><br> Date of publication: <input name="date" type="text"><br> Text of article: <textarea name="text" cols="40" rows="30"></textarea><br> <input type="submit" name="submit" value="Send article"><input type="reset" name="reset" value="Reset form"> </form> <?php } ?> </body> </html>
alvast bedankt
|