Xyphon Posted December 13, 2007 Share Posted December 13, 2007 Hey, I ahve a few tihngs done, login, logout, register, ban, ect. I would like to know, how would I go aobut makign a news comments system. I will make the news with simple tables and echo, no hard things, just edit from host. But I would like to know how a comment system would be made. I would like to display users name, which is of course easy, but I dotn know how to put it so it displays every users name that postred.. Basically, I have no clue how to go about doing this. Can someone tell me some pointers, and tell me how to do this? Thank you, Xyphon. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/ Share on other sites More sharing options...
trq Posted December 13, 2007 Share Posted December 13, 2007 You'd probably find the solution to this type of functionality by looking at some tutorials about creating a blog. It really is a pretty straight forward task, but this isn't really the place for tutorials. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414348 Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Share Posted December 13, 2007 Comment Database table id_comment - INT(11) id_user - VARCHAR(225) title - VARCHAR(225) comment - LONGTEXT date - DATE TIME Basically, create form, then validate the data, and in addition to that, just use // Validate for empty fields, long strings, ...etc // If no errors, then put it in the database $username = $_SESSION['username']; $title = $_POST['title']; $comment = $_POST['comment']; $date = date("Y-m-d h:i:s"); mysql_query("INSERT INTO comments (id_user,title,comment,date) values ('$username','$title','$comment','$date')") or die(mysql_error()); echo 'comment has been posted, thankyou.'; Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414349 Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 Comment Database table id_comment - INT(11) id_user - VARCHAR(225) title - VARCHAR(225) comment - LONGTEXT date - DATE TIME Basically, create form, then validate the data, and in addition to that, just use // Validate for empty fields, long strings, ...etc // If no errors, then put it in the database $username = $_SESSION['username']; $title = $_POST['title']; $comment = $_POST['comment']; $date = date("Y-m-d h:i:s"); mysql_query("INSERT INTO comments (id_user,title,comment,date) values ('$username','$title','$comment','$date')") or die(mysql_error()); echo 'comment has been posted, thankyou.'; How would I make a comment input type? for form. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414358 Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Share Posted December 13, 2007 <table width="39%" border="0" align="center" cellpadding="0" cellspacing="2"> <tr align="left" valign="top"> <td>Title:</td> <td><input name="title" type="text" id="title" value="RE:"></td> </tr> <tr align="left" valign="top"> <td>Comment:</td> <td><textarea name="comment" cols="60" rows="10" id="comment"></textarea></td> </tr> <tr align="left" valign="top"> <td width="18%"> </td> <td width="82%"><input type="submit" name="Submit" value="Post Comment"></td> </tr> </table> This is what you mean? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414362 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 I just ment the Texterea, but thanks. Umm.. Do you know how to go to view? Thats one I really dont understand is how to display the information. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414417 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Comment Database table id_comment - INT(11) id_user - VARCHAR(225) title - VARCHAR(225) comment - LONGTEXT date - DATE TIME Basically, create form, then validate the data, and in addition to that, just use // Validate for empty fields, long strings, ...etc // If no errors, then put it in the database $username = $_SESSION['username']; $title = $_POST['title']; $comment = $_POST['comment']; $date = date("Y-m-d h:i:s"); mysql_query("INSERT INTO comments (id_user,title,comment,date) values ('$username','$title','$comment','$date')") or die(mysql_error()); echo 'comment has been posted, thankyou.'; Thats how. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414418 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Oh I dont mean that. I mean viewcomments.php. And, whats wrong here? <?PHP include('Connect.php'); include('top.php'); $submit = $_POST['submit']; $username = $_SESSION['username']; $comment = $_POST['comment']; if ($submit) { mysql_query("INSERT INTO news_comments (id_user,comment) values ('$username','$comment')") or die(mysql_error()); echo "The comment is successfully posted. Please go <a href='index.php'>back</a>"; } else echo " <html> <form id='frm' method='POST'> <input type='hidden' name='submit' value='1'><br> <textarea name='comment' cols='60' rows='10' id='comment'></textarea><br> <input type='submit' value='Post Comment'> </form> </html>"; include('bottom.php'); exit; ?> I know it wont put in user, since I didnt check for cookie. But why wont it say comment? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414457 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Your form has no action <form id='frm' method='POST'> Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414459 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Its not supposed to lead anywhere else. It's just supposed to edit DB. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414468 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Its not supposed to lead anywhere else. It's just supposed to edit DB. So then you put <form action = "" Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414469 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 The comment is still empty. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414472 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Your form is really clumsy lol try <?php include('Connect.php'); include('top.php'); $submit = $_POST['submit']; $username = $_SESSION['username']; $comment = $_POST['comment']; if ($submit) { mysql_query("INSERT INTO news_comments (id_user,comment) values ('$username','$comment')") or die(mysql_error()); echo "The comment is successfully posted. Please go <a href='index.php'>back</a>"; } else echo " <html> <form action="" method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <textarea name='comment' cols='60' rows='10' id='comment'></textarea><br> <input name="submit" type='submit' id="submit" value='Post Comment'> </form> </html>"; include('bottom.php'); exit; ?> Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414476 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 One, you have else ?> Two, I edited it to ( Three, now I have a stupid Parse error: parse error, unexpected $ in /home/www/ptcrpg.awardspace.com/postcomment.php on line 27 Eww. I dont see anything wrong O.O Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414479 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Fixed it, but it stll displays 0 in comments. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414480 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 try <?php include('Connect.php'); include('top.php'); $submit = $_POST['submit']; $username = $_SESSION['username']; $comment = $_POST['comment']; if ($submit) { mysql_query("INSERT INTO news_comments (id_user,comment) values ('$username','$comment')") or die(mysql_error()); echo "The comment is successfully posted. Please go <a href='index.php'>back</a>"; } else echo " <html> <form action=\"\" method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <textarea name='comment' cols='60' rows='10' id='comment'></textarea><br> <input name=\"submit\" type='submit' id=\"submit\" value='Post Comment'> </form> </html>"; include('bottom.php'); exit; ?> Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414481 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Fixed it, but it stll displays 0 in comments. Is there any data in the DB ? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414482 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Yes there is data. Heres my Create ID_COMMENT INT(11) NOT NULL ID_USER BIGINT(255) NOT NULL COMMENT BIGINT(255) NOT NULL Thats not my file, howver. But its what I used in the inside. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414485 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Post the viewcomments code. Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414487 Share on other sites More sharing options...
teng84 Posted December 14, 2007 Share Posted December 14, 2007 you use bigint(number) in your comment ? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414490 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Nono, I dont have it. I ment it displays 0 in the db. Also, It wont display user... O,o teng84: NO! My Create! Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414491 Share on other sites More sharing options...
teng84 Posted December 14, 2007 Share Posted December 14, 2007 if you declare your field as number and you insert strings i believe it will give you 0 Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414492 Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 id_comment - INT(11) id_user - VARCHAR(225) title - VARCHAR(225) comment - LONGTEXT date - DATE TIME Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414494 Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 id_comment - INT(11) id_user - VARCHAR(225) title - VARCHAR(225) comment - LONGTEXT date - DATE TIME Nah, I dont want title and date. But you cant put dashes, do you mean ID_COMMENT INT(11) NOT NULL, ID_USER VARCHAR(225) ECT And why wont it display user? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414497 Share on other sites More sharing options...
teng84 Posted December 14, 2007 Share Posted December 14, 2007 I'm lost can you explain now your problem? Link to comment https://forums.phpfreaks.com/topic/81587-how-would-i-go-about-doing-this/#findComment-414501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.