|
Posted by finer recliner on 02/27/07 02:59
i've been playing with the below code for a while now, and i cant get
it to work correctly. the user should be able to input text into a
textbox and upon hitting submit, it will append that text to whatever
is in "newpage.html" and write this new chunk of text to data.txt.
the final result of my code will be a bit more elaborate, but i can't
even get this to work. i believe soemthing is wrong the scope of my
variables or how my functions are written or something. it seems
everytime i hit submit, only $text is written to data.txt. $above
seems to be blank in the addHTML function. any suggestions?
thanks!
-dave
/////////////////////////start code ////////////////////////////////
<html>
<head>
<?php
if ($submit) {
$newdata = addHTML($newdata);
$fp = fopen("data.txt", "w");
fwrite($fp, $newdata);
fclose($fp);
}
$fcurrent = fopen("newpage.html", "r");
$i = 0;
while(!feof($fcurrent)){
$line = fgets($fcurrent, 4096);
$above .= $line;
}
fclose($fcurrent);
function addHTML($text){
global $above;
$newdata = $above . $text;
return $newdata;
}//end addHTML
?>
</head>
<body>
<form action="<? print $PHP_SELF; ?>" method="post">
<textarea name="newdata" rows="30" cols="80"></textarea>
<br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
//////////////////////////////////end
code//////////////////////////////////////////
Navigation:
[Reply to this message]
|