PLEASE PLEASE PLEASE READ!! ITS LONG BUT I REALLY NEED THE HELP!!
Hey guys heres my problem, I have a sectionof my site for rating teachers and in this section you can leave comments about the teachers. I have everything put together the only problem is the comment leaving part is a little flaky, sometimes it works and sometimes it doesnt. The code is listed below the first being the form which the people submit their info through and the second being the code that updates the database table. For an example of one of the users I cant add another comment to for a reason unbeknownst to me go to http://www.duparties.com/profrate/view_prof.php?prof=2 and try leaving a comment (I will erase all these eventually so feel free to leave aas many as you want to test if they work).
The PHP code basically takes the inputs and forms them like this in the comments section so they can later be decoded into individual comments.
(--)[--]name1[--]email1[--]course1[--]date1[--]comment1--
For most of the people I attempted leaving comments for it works perfectly but for the Prof. Zoski and a couple of the others when I try making a submission it goes back to the profile view page but did not make the update to the database.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Professor Rater - Add Professor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
</head>
<body>
<div align="center">
<table border="5" cellpadding="0" cellspacing="0" bordercolor="#1F0168" width="350" id="AutoNumber3">
<tr>
<td width="100%"> <p align="center"><b><font face="Arial" size="5">Professor
Rater</font></b></td>
</tr>
</table>
<p><a href="add_prof.htm">Add Professor</a> --- <a href="index.php">View Listings</a></p>
<table border="3" bordercolor="#000099">
<tr align="center">
<td width="361" nowrap bgcolor="#000099"><font color="#FFFFFF">Add a Professor</font></td>
</tr>
<tr align="center">
<td nowrap bgcolor="#CCCCCC">
<table width="100%" border="0" bordercolor="#666666">
<form action="add_prof.php" method="POST">
<tr>
<td width="24%" align="right" nowrap><strong>Your Name:</strong></td>
<td width="76%"><input type="text" name="user_name" size="30"></td>
</tr>
<tr>
<td align="right" nowrap><strong>Your Email:</strong></td>
<td><input type="text" name="user_email" size="30"></td>
</tr>
<tr>
<td align="right" nowrap> </td>
<td> </td>
</tr>
<tr>
<td align="right" nowrap><strong>Professor Name:</strong></td>
<td><input type="text" name="prof_name" size="30"></td>
</tr>
<tr>
<td align="right" nowrap><strong>Department:</strong></td>
<td><select name="department">
<option>Accounting
</option>
<option>Architecture</option>
<option>College of Business</option>
<option>Chemical Engineering</option>
<option>Chemistry</option>
<option>College of IST</option>
<option>Computer Science</option>
<option>Culture and Communication</option>
<option>Decision Sciences</option>
<option>Economics</option>
<option>English and Philosophy</option>
<option>Electrical/Computer Eng.</option>
<option>Fashion Design</option>
<option>Finance</option>
<option>Health Professions</option>
<option>International Studies</option>
<option>IST</option>
<option>Legal Studies</option>
<option>Management</option>
<option>Materials Engineering</option>
<option>Marketing</option>
<option>Mathematics</option>
<option>Mechnical Engineering</option>
<option>Media Arts & Design</option>
<option>Medicine</option>
<option>Night Courses</option>
<option>Performance Arts</option>
<option>Physics</option>
<option>Psychology</option>
<option>Sociology</option>
<option>Visual Studies</option>
</select></td>
</tr>
<tr>
<td align="right" nowrap><strong>Website:</strong></td>
<td>
<input name="website" type="text" value="Dont edit if none..." size="30"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right" valign="top" nowrap><strong>Comments:</strong></td>
<td><textarea name="comments" cols="23" rows="4" wrap="VIRTUAL">Add any comments you have for us here...</textarea></td>
</tr>
<tr>
<td align="right" valign="top" nowrap> </td>
<td> </td>
</tr>
<tr>
<td align="center" valign="top" nowrap colspan="2">
<input type="submit" name="Submit" value="Submit Professor!"></td></form>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>
<?php
$prof = $_POST['prof'];
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$course = strip_tags($_POST['course']);
$comment = strip_tags($_POST['comment'], '<a><b><i><u>');
$comment = str_replace("(--)","",$comment);
$comment = str_replace("[--]","",$comment);
if($name!="" && $comment!="")
{
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("pictures",$db);
$profinfo = mysql_query("SELECT * FROM teachers WHERE prof_id='".$prof."'",$db);
$profrow = mysql_fetch_row($profinfo);
if($profrow[9]=="")
$ammendstring = "(--)";
$origcomments = $profrow[9];
if($email=="dont edit for anonymous...")
$email = "";
$hoursdiff = 3;
$hoursdiff = $hoursdiff * 3600;
$timestamp = time();
$timestamp = $timestamp + $hoursdiff - 720;
$todaydate = date("m/d/Y g:iA", $timestamp);
$ammendstring .= "[--]".$name."[--]".$email."[--]".$course."[--]".$todaydate."[--]".$comment."[--](--)";
$finishedstring = $origcomments.$ammendstring;
$updateinfo = mysql_query("UPDATE teachers SET comments=$finishedstring WHERE prof_id='".$prof."'",$db);
mysql_close($db);
echo "<head>
<script language='javascript'>
alert('Thank you for submitting your comments, we're sending you back to their profile!');
</script>
<META http-equiv='refresh' content='0; url=http://www.duparties.com/profrate/view_prof.php?prof=".$prof."'>
</head>
";
}
else
{
echo "<head>
<META http-equiv='refresh' content='0; url=http://www.duparties.com/profrate/add_comment.php?prof=".$prof."&error=An_error_occurred_please_try_again!'>
</head>
";
}
?>