I have two errors that i can't find out why they happen.
The first one is:
<?php
if (isset($_GET['news']))
{
$article = $_GET['news'];
$file = fopen("news.txt","r") or die("Unable to open file, sorry");
while(!feof($file))
{
$tmp = fgets($file);
if ($tmp == $article)
{
$tmp = fgets($file);
echo '<h1>';
echo $tmp;
echo '</h1>';
$tmp = fgets($file);
echo $tmp;
break;
} else
{
fgets($file);
fgets($file);
}
}
} else
{
echo '<h1>No page specified</h1>You have to specify what news you want to look at.';
}
It doen't output anything at all!
The news.txt file is formatted as:
Short name for links
Header
Text
2:
The next error is:
<?php
if ( isset($_GET['completed']) )
{
echo '<h1>News submitted</h1>The news will appear on the site now';
} elseif(!(isset($_POST['password'])&&isset($_POST['name'])&&isset($_POST['header'])&&isset($_POST['text'])))
{
// I:E print the submit page
echo '
<form action="addnews.php" method="post">
Header: <input type="text" name="header" /><br />
Text (can use html tags, abstain from using <h1>. No newlines in it will be preserved, use <br />):<br />
<textarea rows="10" cols="30" name="text"> This is an example news. Lorem ipsum dolor sit amet. </textarea> <br />
Unique name (can only contain the letters a-z): <input type="text" name="name" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" />
</form>
';
} else
{
if ($_POST['password'] == '******')
{
$tmp = str_replace('\n','<br />',$_POST['text']);
$file = fopen("news.txt","a") or die("Unable to open file, sorry");
fputs($file, $_POST['name']);
fputs($file, "\n");
fputs($file, $_POST['header']);
fputs($file, "\n");
fputs($file, $tmp);
fputs($file, "\n");
echo '<script>document.location="http://***********.x10hosting.com/index.php?p=addnews.php&completed=true";</script>';
} else
{
echo '<h2>Invalid password</h2>
<b>Sorry, the password you supplied was invalid! <a href="http://**********.x10hosting.com/index.php?p=addnews.php">Try again.</a></b>';
}
}
Simply, it doesn't print it to the file in the correct format.

New Topic/Question
Reply




MultiQuote





|