Bakurei
Spy
- Joined
- Jun 27, 2004
- Messages
- 980
- Reaction score
- 0
For starters my knowledge of PHP is about 1h of reading and 3h of toying around. So now to the bussines, could someone please tell me whats wrong with these codes (trying to get a news posting system working).
And the other one:
Thank you.
PHP:
<html>
<head>
<title>Admin sivun testaus</title>
<link href="style.css" type="text/css">
</head>
<body>
<?php
$news = file("news.txt");
$news = array_reverse($news);
$amount = count($news);
for ($i = 0; $i < $amount; $i++) {
$info = explode( "|", $news[$i], 5);
$top = $info[0];
$time = $info[1];
$newstitle = $info[2];
$message = $info[3];
$bottom = $info[4];
echo $top . $newstitle . $message $bottom;
}
?>
</body>
</html>
And the other one:
PHP:
<?php
if (!isset($_POST['name'])) {
?>
<html>
<head>
<title>Viestin lähetys</title>
</head>
<body>
<h1>Viestin lähetys</h1>
<form action="undex.php" method="post">
Name: [br] <input type="text" name="name"> [br]
Title: [br] <input type="text" name="newstitle"> [br]
Message: [br] <textarea name="message"></textarea> [br] [br]
<input type="submit" value="Send">
</form>
</body>
</html>
<?php
} else {
$file = fopen("news.txt", "a");
$top = '<table cellspacing="0" cellpadding="0" width=820 align="center" ><tr><td>[img]img/yla_vasen.gif[/img]</td><td></td><td>[img]img/yla_oikea.gif[/img]</td></tr><tr><td></td><td width=800>';
$newstitle = '<span>[img]img/Avatar_Akurei-.png" align="right" >[i]'. $_POST['name'] . '[/i][b]' . $_POST['newstitle'] . '[/b][br]<hr>';
$message = '<p>' . $_POST['message'] . '</p></span>';
$bottom = '</td><td></td></tr><tr><td>[img]img/ala_vasen.gif" width=10 height=10 border=0 ></td><td></td><td>[img]img/ala_oikea.gif" width=10 height=10 border=0 ></td></tr></table>[br]';
$time = time();
$row= "$top|$time|$newstitle|$message|$bottom \n";
fwrite($file, $row);
fclose($file);
header("Location: undex.php");
}
?>
Thank you.