Forum Moderators: coopster

Message Too Old, No Replies

space upon button pressed

weird but simple reason im sure

         

kumarsena

5:53 pm on Nov 12, 2004 (gmt 0)

10+ Year Member



i ahve a comment script that prints a form and reads comments from a flat file. it worked but all of a suddeen, it is acting funny. when i press the submit comment button a couple of blank lines are added to the bottom(where underneat all the comments)as if a new comment was added. then teh secnd press does what it is suppoed to do...but if therea are comments already then it doesnt do that, i havent got a clue as to what is going on, so here is the comment form and script that prints the comments
sory abt posting teh whole code here, but i couldnt figure it out...

<?php

//print title
echo '<h3>Comment On This Article</h3><br />';

//print form
echo "<form method=\"POST\" name=\"comment\" action=\"save_cmt.php?art=$art\">
Name<br><input type=\"text\" name=\"name\" size=\"20\"><br>

Comment<br><textarea name=\"comment\" rows=\"5\" cols=\"20\"></textarea><br />
<input class=\"button\" type=\"submit\" name=\"submit\" value=\"OK\">

</form>";
//get article name- testing only

//$art = $_GET['art'];
//$_POST['submit'] == false;

//change file extension to .cmt, thats the format we have used for the comment file
$comment_file = str_replace('txt', 'cmt', $art);

//if comment file exists, read and print comments
if (file_exists($comment_file))
{
$file_array = file($comment_file);
//echo $file_array;
foreach($file_array as $line)
{
$line_array = explode("¦", $line);
echo '<strong>'.$line_array[0].'</strong>'.'<br/ >';
echo '<font class="date">'.$line_array[1].'</font>'.'<br/ >';
echo '<i>'.$line_array[2].'</i>'.'<br/ ><br />';
}
}
else
{
echo 'no comments';

}

?>

and here is the save comment script...


<?php
if (!isset($_POST['name']) ¦¦ empty($_POST['name']) ¦¦!isset($_POST['comment']) ¦¦ empty($_POST['comment']) )
{
echo 'please fill in the form if you wish to comment';
}

else
{

//echo $_POST['name'].'<br />';
//echo $_POST['comment'].'<br />';

$today = date("F j Y g:i a");

$name = $_POST['name'];
$comment = $_POST['comment'];

$art_file = $_GET['art'];
$comment_file = str_replace('.txt', '.cmt', $art_file);

//echo $art_file.'<br />';
//echo $comment_file.'<br />';

$content = $name.'¦'.$today.'¦'.$comment."\r\n";
//echo $content;

$fh = fopen($comment_file, 'a');
fwrite($fh, $content);

fclose($fh);
//header('Location: index.php?art=$art_file;');
echo 'comment has been added.';
echo $_SERVER['PHP_SELF'];

}




?>

kumarsena

6:09 pm on Nov 12, 2004 (gmt 0)

10+ Year Member



on second thught, i dont think this has much to do wiht the php script scripts, but something happens when i pressed the button and before i even release it.

kumarsena

2:08 pm on Nov 15, 2004 (gmt 0)

10+ Year Member



hye again, i have checked and re checked bu this problem persists,,,,and it is nothing to do with the css as first assumed by me..so if anyne wants to ahve a look, the i can sicky the add...

tnx k

benlieb

4:53 am on Nov 16, 2004 (gmt 0)

10+ Year Member



How many browsers have you tested this in?
Sounds like maybe a browser issue.

benlieb

4:54 am on Nov 16, 2004 (gmt 0)

10+ Year Member



Wait are the extra lines appearing in the html code or on the browser?

kumarsena

9:08 pm on Nov 16, 2004 (gmt 0)

10+ Year Member



ive tested in ie as well, but the script doesnt wolrk there,but the problem doenst occur when the button is pressed. the problem appears in firefox.

the linesapepar in the browser. i will sticky u the add,,,,hope u dont mind,,

kumar