Page 1 of 1

priblem with forum reply script!

Posted: Mon Dec 08, 2003 11:29 am
by dull1554
heres my code
add_reply.php

Code: Select all

<html>
<head>
</head>
<body>
<form method="post" action="add_reply.php">

Subject:<br><input type="text" name="subject">
<br>
Reply body:<br><textarea cols="75" rows="25" name="body"></textarea>
<br>
<input type="submit" value="reply">
</form>

</body>
</html>
<?php
$filename = $_GET['reply'];
$reply_body = $_GET['body'];
$username = (@$_COOKIE['complexscriptingusername']);
$insertreply = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='80%' border='1' bgcolor='whitesmoke'>".$reply_body."</td>
<td width='20%' border='1' bgcolor='whitesmoke'>
Reply by: ".$username."</td></tr></table>";
$fp = fopen($filename, "a");
fwrite($fp,$insertreply);
fclose($fp);
?>
i get this error when i got to the script

Code: Select all

Notice: Undefined index: body in d:\web\dull1554\forum\add_reply.php on line 20
and if i try to submit the forum i get these,

Code: Select all

Notice: Undefined index: reply in d:\web\dull1554\forum\add_reply.php on line 19

Notice: Undefined index: body in d:\web\dull1554\forum\add_reply.php on line 20

Warning: fwrite(): supplied argument is not a valid stream resource in d:\web\dull1554\forum\add_reply.php on line 27

Warning: fclose(): supplied argument is not a valid stream resource in d:\web\dull1554\forum\add_reply.php on line 28

Posted: Mon Dec 08, 2003 11:36 am
by Nay
Check these two:

$filename = $_GET['reply'];
$reply_body = $_GET['body'];

Undefined index means that the variables are not stated.

And didn't I run into you with a heredoc suit already? :lol:

-Nay

Posted: Mon Dec 08, 2003 11:54 am
by McGruff
Form method is POST (good) but you're looking for vars in $_GET.

Try this to check POST vars:

Code: Select all

<?php
echo '<pre>';
print_r($_POST);
echo '</pre>';
?>