I'm very new to perl, infact this is my first accomplishment so far. So, please bear with me while I try to learn from the best.

My question is how can I change this script to allow my users to edit the data they posted? For example if one of my analysts forget to add a comment or make a typo, I'd like them to be able to click a link, on the page that contains the post, edit the content and then click "save" or "resubmit".

#!/usr/bin/perl -w use strict; use CGI qw(:standard); use DBI; print header, start_html("Daily Communication Log"); print "<a href = /form.html>Submit New Log Entry</a><br><br>"; # Declare variables my ( $analyst, # name of the analyst making the entry $name, # name from combo box on html form $shift, # shift analyst is on $cust, # new customer turn up $issues, # customer specific issues analysts should be aware of $eoi, # events that require observation $message, # general comments not related to previous fields $cur, # keeps current entries $dbh, # database handler $filter, # escapes single quote $sql, # handles statements $stq, # does query ); $cur = CGI->new(); #hold current request $message=$cur->param("message"); $cust=$cur->param("cust"); $issues=$cur->param("issues"); $eoi=$cur->param("eoi"); $analyst=$cur->param("analyst"); ($shift,$name)=split(/:/,$analyst); # Connect to Database $dbh = DBI->connect("DBI:mysql:dcl:localhost","user","passwd"); if ($message) { # SQL Statement $stq = $dbh->prepare( qq{ insert into dcl_log values(now(),"$name","$s +hift","$cust","$issues","$eoi","$message") }); $stq->execute || print "Unable to execute MySQL statement"; } # Execute query and print after values have been entered # Need to see the last 5 entires in reverse order $sql = "select * from dcl_log order by timestamp desc limit 5"; $stq = $dbh->prepare($sql); $stq->execute || print "Could not complete SQL statement ... check syntax." +; # Output results my @row; while (@row=$stq->fetchrow_array) {table_data (@row);} $dbh->disconnect(); print end_html; sub table_data { my @data = @_; my %D; print "<center><table border=0 width=100%>"; $D{'time'} = $data[0]; $D{'name'} = $data[1]; $D{'shift'} = $data[2]; $D{'cust'} = $data[3]; $D{'issues'} = $data[4]; $D{'eoi'} = $data[5]; $D{'message'} = $data[6]; print "<tr><td colspan=2 align=center><b>$D{'time'}</b></td></tr>\n"; print "<tr><td width=1% align=left><b>Name:</b>\n"; print "<td align=left>$D{'name'}</td></tr>\n"; print "<tr><td align=left><b>Shift:</b>\n"; print "<td align=left>$D{'shift'}</td></tr>\n"; print "<tr><td align=left><b>Customer:</b></td></tr>\n"; print "<tr><td colspan=2 align=left>$D{'cust'}</td></tr>\n"; print "<tr><td align=left><b>Issues:</b></td></tr>\n"; print "<tr><td colspan=2 align=left>$D{'issues'}</td></tr>\n"; print "<tr><td align=left><b>EOI:</b></td></tr>\n"; print "<tr><td colspan=2 align=left>$D{'eoi'}</td></tr>\n"; print "<tr><td align=left><b>Message:</b></td></tr>\n"; print "<tr><td colspan=2 align=left>$D{'message'}</td></tr>\n"; print "</table></center><hr>\n"; }

janitored by ybiC: Balanced <readmore> tags around longish codeblock, as per Monastery convention


In reply to Editing Posted Data by ejx2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.