Peter Brodersen:
> On Sun, 10 Aug 2003 18:35:40 +0200, Jan V.Pedersen
> <janvidar_rem_this_@start.no> wrote:
>
> >Jeg får feil ved å bruke disse variablene.
>
> Hvilken fejl får du?
Warning: fopen("", "r") - No error in c:\phpdev\www\trening\kap_6
\chapter6\dynamic_template.php3 on line 42
Warning: fread(): supplied argument is not a valid File-Handle resource
in c:\phpdev\www\trening\kap_6\chapter6\dynamic_template.php3 on line 43
Warning: fclose(): supplied argument is not a valid File-Handle resource
in c:\phpdev\www\trening\kap_6\chapter6\dynamic_template.php3 on line 44
> Og hvad indeholder $article?
Artikkel er en html-fil som heter "article.html"
Her er hele scriptet:
---------------------------
<html>
<head>
<title>The Dynamic Article</title>
</head>
<body>
<?
if(isset($format)):
if($format == "print"):
$file = fopen($article, "r");
$data = fread($file, 1000);
fclose($file);
$stripped_data = strip_tags($data);
print("<pre>$stripped_data</pre>");
elseif($format == "email"):
?>
<h2>Send Article</h2>
<form action="dynamic_template.php3" method="POST">
<p>Send to Email: <input type="text" name="to">
<br>Your Email: <input type="text" name="from">
<br>Short Comment: <input type="text" name="comment">
<input type="hidden" name="article" value="<? echo $article
?>">
<br><input type="submit" name="submit" value="Send It!">
</form>
<?
endif;
elseif(isset($submit)):
$file = fopen($article, "r");
$data = fread($file, 1000);
fclose($file);
$stripped_data = strip_tags($data);
$body = "Comments from sender: " . $comment . "\n\n" .
$stripped_data;
$subject = "Check This Article Out!";
mail($to, $subject, $body, "FROM: $from");
?>
<h2>Email has been sent</h2>
<hr>
<?
print("To: $to<br>From: $from<br>Subject: $subject<p><pre>$body
</pre><hr>\n");
else:
$file = fopen($article, "r");
$data = fread($file, 1000);
fclose($file);
print("$data");
?>
<hr>
<p>Format this article for <a href="dynamic_template.php3?article=
<? echo $article ?>&format=print">printing</a>!
<br><a href="dynamic_template.php3?article=<? echo $article ?>
&format=email">Send</a> this article to a friend!
<?
endif;
?>
</body>
</html>
-------------------------------------------
--
mvh Jan Vidar
www.janvidar.com