hgkhkhk Posted November 12, 2017 Share Posted November 12, 2017 I am building a comment section for my system. While it is working successfully, I cannot seem to style the comments the way I want to. All the comments appear at the very left side of the screen. Essentially I want to bring them to the center, color the username, and maybe put a border around the username and comments. I have tried everything such as using span classes and div classes, but nothing is working. If someone could please tell me where to put the span or div classes, I would appreciate it. Thank you. <?php if($_POST) { $name = $_POST['name']; $content = $_POST['commentContent']; $handle = fopen("comments.html","a"); fwrite($handle,"<b>" . $name . "</b>:<br/>" . $content . "<br/><br>"); fclose($handle); } ?> <!doctype html> <html> </head> <link rel="stylesheet" type="text/css" href="commentstyle.css"> <link rel="icon" href="Icon.jpg"> <title>Comment</title> </head> <body> <div class="header"> <img class="icon" src="Icon.jpg"> <div class="search">Comment </div> </div> <a href="homepage.php"><span class="home">Homepage</span></a> <div class="select">View comments</div> <br> <?php include "comments.html"; ?> <hr> <div class="box"> <form action = "" method = "POST"> Name:<br> <input type = "text" name = "name"><br/> Comment: <textarea rows = "10" cols = "30" name = "commentContent"></textarea><br/> <input type = "submit" value = "Submit"><br/> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/305640-php-and-css-how-to-style-comment-site/ Share on other sites More sharing options...
Solution requinix Posted November 12, 2017 Solution Share Posted November 12, 2017 You have a much larger problem than just the styling of the comments: people can execute PHP code on your site, let alone put HTML (and Javascript) on your site. Do you want people to write HTML? Please say no because allowing that is painful. Replace with and fwrite($handle,"" . $name . ":" . $content . "");with fwrite($handle,"" . htmlspecialchars($name) . ":" . htmlspecialchars($content) . "");Now go into your comments.html and make sure there isn't anything bad in it. With that taken care of, find and fix the problem with your starting tag. I expect the browser was able to recover gracefully from it, though, as you would have noticed otherwise. Anyways, If you need help with the appearance of your site then we need to see the HTML (your PHP isn't complicated so that's okay) and the CSS. Preferably with a link to the site, but don't provide a link until you do the comment thing I said above. Quote Link to comment https://forums.phpfreaks.com/topic/305640-php-and-css-how-to-style-comment-site/#findComment-1553720 Share on other sites More sharing options...
hgkhkhk Posted November 12, 2017 Author Share Posted November 12, 2017 @requinix Thank you so much for your help. I have done everything as you explained above and have also managed to solve the styling problem. Your help is appreciated, Quote Link to comment https://forums.phpfreaks.com/topic/305640-php-and-css-how-to-style-comment-site/#findComment-1553721 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.