My html file:
<html>
<head><title>RSS Form</title></head>
<body>
<form method='post' action='write.php'>
<img src='logo.png' align='left' />
<font size='6'>RSS Feed</font><br>
The feed that just keeps on giving...<br>
<p>Title:<br>
<input type='text' name='title' size='84' /><br></p>
<p>Article Body:<br>
<textarea rows='20' cols='100' wrap='physical' name='desc'></textarea><br></p>
<input type='submit' value='Post RSS' name='submit'> (Be sure to review the article before pressing this button -- <b>there's no going back</b>)</form><br>
</body>
</html>
and Write.php
<html><body>
<?php
$file_name = 'rss.xml';
if !(file_exists($file_name)) {
initialize_xml($file_name);
}
$rss = fopen($file_name, 'w+') or die('can\'t open file');
remove_tags($rss);
write_content($rss);
close_tags($rss);
finish();
function initialize_xml($name) {
$rss = fopen($name, 'w') or die('can\'t open file');
fwrite($rss, "<?xml version=\"1.0\" ?>\n");
fwrite($rss, "<rss version=\"2.0\">\n");
fwrite($rss, "<channel>\n");
fwrite($rss, "<title>---</title>\n");
fwrite($rss, "<description>This feed will keep users up to date on IT issues that may arise</description>\n");
fwrite($rss, "<link>---</link>\n");
fwrite($rss, "<managingEditor>---</managingEditor>\n");
fwrite($rss, "<webMaster>---</webMaster>\n\n");
close_tags($rss);
fclose($rss);
}
function write_content($rss) {
fwrite($rss, '<item>\n');
fwrite($rss, '<title>');
fwrite($rss, $_POST['title']);
fwrite($rss, '</title>\n');
fwrite($rss, '<description>');
fwrite($rss, $_POST['desc']);
fwrite($rss, '</description>\n');
fwrite($rss, '<date>');
$today = getdate();
$timestamp_format = $today[weekday] + ' ' + $today[month] + ' ' + $today[mday] + ' ' + $today[hours] + ' ' + $today[minutes] + ' ' + $today[seconds];
fwrite($rss, $timestamp_format);
fwrite($rss, '</date>');
}
function close_tags($rss) {
fwrite($rss, '</channel>\n');
fwrite($rss, '</rss>\n');
fwrite($rss, '</xml>\n');
}
function remove_tags($rss) {
// go to end of file
// remove last 3 lines
}
function finish() {
echo 'The article ';
echo $_POST['title'];
echo ' has been added to the feed.\n';
echo '<a href="index.html">Go Back</a>';
}
?>
</body></html>
This is my first contact with PHP so I'm quite confused. When I go to the html page and "submit" my form, I get redirected to:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.
Thanks for your help
\nin it that uses apostrophes (') won't work. It has to be within double quotes ("). - stealthyninja$today[weekday],$today[month], etc., should be$today['weekday'],$today['month'], etc. - stealthyninja