Ok, what I am trying to do is a simple guestbook. The files I am using are guestbook.html, for viewing the entries, addguest.html, for gathering the data via an html form with at least the following data, user name and a message:
user name is a simple text box.
message is a textarea.
I also use guestbook.php for all of my form parsing and what not.
So, guestbook.html calls addguest.html via a '<a href' link where addguest.html is basically just the form that has an action = "guestbook.php", so you could just say that addguest.html calls guestbook.php to parse form data. When things check out ok and I am ready to save the message, which I am trying to store in guestbook.html, I open guestbook.html and look for the html comment "<!--begin-->" so that I can add the new message after the comment. Here is a code snipit:
$env_vars['guestbookreal'] = "guestbook.html";
...
$file = fopen ("{$env_vars['guestbookreal']}", "a+");
if (!$file)
{
print ("<p>Unable to open remote file.\n");
}
$begin_edit = 0;
while (!feof ($file)) {
$line = fgets ($file);
if (eregi ("<!--end-->", $line, $out)){
$begin_edit = 0;
}
if ($begin_edit == 1) {
fwrite ($file, "{$f_data['message']}");
}
if (eregi ("<!--begin-->", $line, $out)) {
$begin_edit = 1;
}
}
fclose($file);
Again, I'm not even sure if this is the right way to attempt this, but this is why I am here asking. I did not mean to suggest that any of what I was writting was perl, I only meant that I had this working in perl and was trying to convert it to php, mainly just for learning purposes. In other words I'm trying to lean php a bit better than I already know it.
If this is still unclear then I will struggle thru it hacking my way as I go an I appologize for chewing up your time.
Thanks,
pcp