On Wed, 24 Oct 2001 07:03, [EMAIL PROTECTED] wrote:
> Hi all, I've got a question that I'm sure can be answered, but I'm a
> little stuck right now...
>
> I've set up yelvington's excellent annotate script, and it works
> beautifully. My next step was to try to add an auto email function to
> notify me when someone has posted a comment, and send me the entire
> question list. (I'll be using this for client feedback)
> Everything works extremely peachy, EXCEPT the mail gets posted on
> every page update, not just on the button press.
>
> So the question is... is there a way to create this feature that only
> occurs when the submit button is pressed?
>
> Below is the code in it's entirety, with this code:
> <?require($DOCUMENT_ROOT . "/annotate.php3"); ?>
> being placed in the html document.
>
> Thanks a million in advance. (btw, if you do choose to answer this,
> cc me as well, as I'm on digest.)
>
> Jeff
>
> /***************************************/
> <?PHP
> if ($message)
>       {
>       $message = ereg_replace("\r\n\r\n", "\n<P>", $message);
>       $date = date("l, F j Y, h:i a");
>       $message = "<B>$name </B> -- $date<P> $message <BR><HR>";
>       $fp = fopen (basename($PHP_SELF) . ".comment", "a");
>       fwrite ($fp, $message);
>       fclose ($fp);
>       }
> @readfile(basename(($PHP_SELF . ".comment")));
>
> // function to open a file and place the file into
> //a buffer for further processing
> function open_template($template_file)
> {
>       $i;
>       $output;
>
>       $temp = file($template_file);
>
>       for ($i=0; $i<count($temp); $i++)
>      {
>            $output .= $temp[$i];
>       }
>
>       return $output;
> }
>
> //open the file
> $buffer = open_template(basename($PHP_SELF) . ".comment");
>
> //do some text processing so the email gets plain text, rather
> //than html formatted text
>
> //replace html rules with returns
> $buffer = str_replace("<HR>", chr(10), $buffer);
> //replace html breaks with returns
> $buffer = str_replace("<BR>", chr(10), $buffer);
> //strip all other html tags
> $buffer = strip_tags($buffer);
>
> //email away...
> mail("[EMAIL PROTECTED]", "Auto Form Reply", $buffer);
> ?>
>
>
> <FORM method="post">
> <b>Your name:</b><BR><INPUT name="name" type="text" size="55"><BR>
> <b>Your comment:</b><BR><TEXTAREA name="message" rows=10 cols=55
> wrap=virtual> </TEXTAREA><BR>
> <INPUT name="submit" type="submit" value="Post your comments">
> </FORM>

You might also do a check on whether $submit is empty; if so, don't do 
any processng that isn't relevant.

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   I can't use Windows. The cat ate my mouse.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to