I started having a go at some PHP yesterday. I successfully coded a small BBCodeParser which I am proud of
I decided to code a small shoutbox.
I get 4 errors with my code:
Quote
Notice: Undefined index: name in C:\Program Files\EasyPHP 2.0b1\www\Chat\index.php on line 20
Notice: Use of undefined constant message - assumed 'message' in C:\Program Files\EasyPHP 2.0b1\www\Chat\index.php on line 21
Notice: Undefined index: message in C:\Program Files\EasyPHP 2.0b1\www\Chat\index.php on line 21
Here is my code:
<?php
//Simple Shoutbox
//Coded by Ben Youle AKA kozine
//BBcodeparser
function bbcode($str)
{
$bbcode = array
(
'[b]' => '<b>',
'[/b]' => '</b>',
'[u]' => '<u>',
'[/u]' => '</u>',
);
$str = str_replace(array_keys($bbcode), array_values($bbcode), $str);
return $str;
}
//Define the form variables to be wrote to the text file
$name = $_POST[name];
$message = $_POST[message];
//Open the file and add it to the variable $chat
$chat = fopen("chat.log", "r+");
//Write to the text file
fwrite($chat, $name, $message);
//Close the file
fclose($chat);
?>
<html>
<head>
<title>Simple Shoutbox</title>
</head>
<body>
<form method="post" action="index.php" name="messageform">
Name:<br>
<input type="text" name="name" id="name" size="50" maxlength="100"><br><br>
Message:<br>
<input type="text" name="message" id="message" size="50" maxlength="100"><br><br>
<input type="submit" value="Submit"><img src="spacer.gif" width=5 height=1 alt="spacer">
<input type="reset" value="Try again"></form>
You can use the following BBcodes:<br><br>
Bold: [b]Text Here[/b]<br>
Underline: [u]Text Here[/u]
</body>
</html>
I think you should be able to see what i'm doing.
Any help would be appreciated
