Handle Post

Requests like edit and links answer forms which allow some fields of the db record to be updated. Here we handle a post by merging whatever fields were present on the form with those in the db.

  sub HandlePost {
    $title = $CookedInput{post};
    dbmopen(%db, $DataBase , 0666) || &AbortScript("can't open $DataBase for update\n");
    %old = &RetrievePage($title);
    for (keys(%CookedInput)) {
        next if /post/ || /form/ || /title/;
        $old{$_} = $CookedInput{$_} if $CookedInput{$_};
    &ReplacePage($title, *old);

Update recent changes. Remove the title if it appears; add today's date unless it appears; then add the title and host that posted it.

A blank after $title in the search avoids matching pages that only began with $title. -- DaveSmith August 23, 1997

Removed one of the \n's after $DateToday to save some vertical space. The leading \n ensures that there's a blank line between dates if $title gets moved. --DaveSmith 12/29/97

    %rc = &RetrievePage(RecentChanges);
    $rc{text} =~ s/\t\* $title .*\n//;
    $rc{text} .= "\n$DateToday\n" unless $rc{text} =~ /$DateToday/;
    $rc{text} .= "\t* $title . . . . . . $ENV{REMOTE_HOST}\n";
    &ReplacePage(RecentChanges, *rc);
I think this assignment should go here instead...--TomStambaugh
    $anchor = &AsAnchor($title);

Report success with a short thank you and a reference to the new page.

    print <<EOF ;
      <head><title>Thanks for $title Edits</title></head>
        Thank you for editing $anchor.<br>
        Your careful attention to detail is much appreciated.<br>
        <img src="$SignatureUrl"><br>
        p.s. Be sure to <em>Reload</em> your old pages.<br>


Last edited November 21, 2001
Return to WelcomeVisitors