Jump to content

Help with posting comments....


L

Recommended Posts

alright...i can't seem to find what's wrong with my code. here it is,

 

<?PHP
include("db.php");
?>
<form id='1' name='1' method='post'>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
   <tr>
      <td><div align="right">Username:   </div></td>
       <td><input name="username" type="text" size="30" value=""></td>
   </tr>
    <tr>
      <td><div align="right">Contact:   </div></td>
      <td><input type="text" name="contact" size="30" value=""> <i>(Email Address)</i></td>
    </tr>
    <td><div align="right">Subject:   </div></td>
    <td><input type="text" name="subject" size="30" value=""></td>
    </tr>
    <tr>
      <td><div align="right">Comment:   </div></td>
      <td><textarea name="comment" cols="45" rows="5" wrap="VIRTUAL"></textarea></td>
    </tr>
    <tr>
      <td></td>
      <td colspan="2">     
        <input type="submit" name="submit" value="Add Comment"></td>
    </tr>
  </table>
</form>
<?PHP
$user = addslashes(strip_tags($_POST['username']));
$contact = addslashes(strip_tags($_POST['contact']));
$subject = addslashes(strip_tags($_POST['subject']));
$comment = addslashes(strip_tags($_POST['comment']));
$date = date("F j, Y.");
$check = @mysql_num_rows(mysql_query("SELECT * FROM `comments` WHERE `comment`='".$comment."' "));
if ($_POST['submit']) {
  if ($check >= 1) { // Check to see if comment already exists
  echo "Comment has already been posted!"; }
  elseif ($contact == NULL || $subject == NULL || $comment == NULL || $user == NULL) {
   echo "Please fill in all fields."; }
   else {
   mysql_query("INSERT INTO `comments` (`user`, `contact`,`subject`,`comment`,`date`) VALUES ('".$user."','".$contact."','".$subject."','".$comment."','".$date."')");
   echo "Comment has been posted! <META HTTP-EQUIV=\"REFRESH\" CONTENT=\"2; URL=/commentform.php\">"; }
   }
?>
<table width="35%" cellspacing="2" cellpadding="2" border="2">
<tr>
<td> User </td><td> Comment </td>
</tr>
<?PHP
$newsid = $_GET['newsid']; $find = mysql_query("SELECT * FROM `comments` WHERE `newsid`='".$newsid."' ORDER BY `id` DESC LIMIT 0,50");
($view = mysql_fetch_array($find))

$fetch = mysql_query("SELECT * FROM `comments` ORDER BY `id` DESC LIMIT 0,50"); // Display last 50 comments
$ip = $_SERVER['REMOTE_ADDR'];
$okip = "My IP";
while ($view = mysql_fetch_array($fetch)) {
if ($ip == $okip) {
echo "<tr><td><a href=\"mailto:".stripslashes($view['contact'])."\">".stripslashes($view['user'])."</a><br>".$view['date']."<br><center><a href=\"commentform.php?del=".$view['id']."\">[X]</a></center></td><td><textarea name=\"textarea\" cols=\"25\" rows=\"4\" wrap=\"virtual\" readonly>".stripslashes($view['comment'])."</textarea></td></tr>";
}
else {
echo "<tr><td><a href=\"mailto:".stripslashes($view['contact'])."\">".stripslashes($view['user'])."</a><br>".$view['date']."</td><td><textarea name=\"textarea\" cols=\"25\" rows=\"4\" wrap=\"virtual\" readonly>".stripslashes($view['comment'])."</textarea></td></tr>";
}
}
?>
</table>
<?PHP
$comment = $_GET['del'];
if ($comment != NULL && is_numeric($comment)) {
  if ($ip == $okip) {
mysql_query("DELETE FROM `comments` WHERE `id` = '".$comment."' LIMIT 1 ");
echo "Comment has been deleted.<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"2; URL=commentform.php\"> ";
}
else {
echo "You do not have permission to delete comments."; }
}
?>

i uploaded it to http://taizkul.prohosts.org/commentform.php

 

-Thank you for your time

~L

Link to comment
Share on other sites

ooohhh....haha...well i want there to be four fields where you can input info like a name, contact, subject, and the message. Then the page reloads to show your post and the date next to it. The problem im having is that when i upload it to, http://taizkul.prohosts.org/commentform.php, the screen turns blank. I'm not sure what i did wrong because it all looks fine to me.

 

Then i have code where an X shows so i can delete spam comments...but it only shows with my ip address...

 

and then when this problem is fixed...i was wondering if you could help me with having comments posted for specific news articles

Link to comment
Share on other sites

ooohhh....haha...well i want there to be four fields where you can input info like a name, contact, subject, and the message. Then the page reloads to show your post and the date next to it. The problem im having is that when i upload it to, http://taizkul.prohosts.org/commentform.php, the screen turns blank. I'm not sure what i did wrong because it all looks fine to me.

 

Then i have code where an X shows so i can delete spam comments...but it only shows with my ip address...

 

and then when this problem is fixed...i was wondering if you could help me with having comments posted for specific news articles

 

ASTIG!!! ILL take a look

Link to comment
Share on other sites

its really empty maybe to debug it remove the <?PHP

include("db.php");

?> first and look if theres any cahnges if still no action happened i should say you are uploading the wrong file be sure that the file u upload is on right track ya know!!!!

 

ASTIG!!

Link to comment
Share on other sites

hmm...i reuploaded the file, and i took out to include and it still shows a blank page. Then i pasted the include back in and made sure i was uploading the right file because i checked before uploading.....does anyone know the solution to my problem because apparently the code is correct.

 

Also the weriod thing is that this was working like two days ago...but now it isn't, :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.