View Single Post
Old 01-18-2006, 11:42 AM   #1
NPeart1
Green Mole
 
Join Date: Dec 2005
Posts: 2
PHP form processing problem - Please advise

I have a php form that only partially works:

1.) The php script displays user comments in HTML. The comments are submitted into an SQL database through a php web form. When comments are first written to the database, they are given an "N", which means that the comment hasn't been physically responded to by a member of the development team.

2.) When you first load the page, reply.php, it lists all open comments. After a particular comment has been physically responded to by a member of the development team, the developer will click the Close button next to a particular comment. Clicking close should update the record in the database with a "Y" while refreshing the page with the remaining (or open) comments (the comment that was just closed should not display again, but does).

Does anyone have any advise regarding the code below?

Thanks in advance for any help!

<?

if(!empty($reply)) {

$connection_string = 'DRIVER={SQL Server};SERVER=ebsqlc1.com\ebs_sql;DATABASE=PPAD';

$user = 'PPadUser';
$pass = 'rmot22';

$connection = odbc_connect( $connection_string, $user, $pass );

$query = "UPDATE contactd SET reply = 'Y' WHERE seqNum = '$reply'";

$result = odbc_exec($connection,$query)
or die("Query Failed: ".odbc_error()." - ".$query);

}

$connection_string = 'DRIVER={SQL Server};SERVER=ebsqlc1.com\ebs_sql;DATABASE=PPAD';

$user = 'PPadUser';
$pass = 'rmot22';

$connection = odbc_connect( $connection_string, $user, $pass );

$query = "Select * from contactd where reply = 'N'";

$result = odbc_exec($connection,$query)
or die("Query Failed: ".odbc_error()." - ".$query);

$trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);

while ($row = odbc_fetch_array($result)) {
$name = str_replace('+',' ',urlencode(stripslashes($row['name'])));
$subject = str_replace('+',' ',urlencode(stripslashes($row['subject'])));
$body = str_replace('+',' ',urlencode(stripslashes($row['comments'])));

$date = substr($row['date'],0,10);

echo "<form name=$row[seqNum] method=POST action=reply.php>";
echo "<tr>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1>$date</font></td>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1>$row[name]</font></td>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1>$row[empNum]</font></td>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1><a href=\"mailto:$row[email]?subject=RE: $subject&body=$name:%0D%0A%0D%0A%0D%0A On $date You Wrote: %0D%0A%0D%0A$body\">$row[email]</a></font></td>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1>$row[deptSta]</font></td>\n";
echo "<td><font face=Tahoma,Arial,Helvetica size=1>$row[mailList]</font></td>\n";
echo "<td><input type=hidden name=reply value=$row[seqNum]><font face=Tahoma,Arial,Helvetica size=1><input type=submit name=close value=Close></font></td>\n";
echo "</tr>\n";
echo "<tr><td colspan=7><font face=Tahoma,Arial,Helvetica size=1><b>Subject:</b> $row[subject]</font></td></tr>\n";
echo "<tr><td colspan=7><font face=Tahoma,Arial,Helvetica size=1><b>Comments:</b> $row[comments]</font></td></tr>\n";
echo "</form>";

}

?>
NPeart1 is offline   Reply With Quote