UOTS-Owner Posted April 15, 2021 Share Posted April 15, 2021 Hi guys, need some help when I replace id = 'msg' to id = 'editor1' it wont post the error You must enter a comment to post appears but I need id set to editor1 for the text editor to work any ideas? if($user['usr_flastp'] > time()) { echo "<p_title>New topic</p_title> <hr>"; echo warn("You must wait one minute between each post/reply."); echo "<hr>"; exit; } $_GET['id'] = preg_replace('/[^0-9]/', '', $_GET['id']); $_GET['a'] = preg_replace('/[^a-z]/', '', $_GET['a']); $_POST['msg'] = strip_tags(stripslashes($_POST['msg'])); $_POST['title'] = strip_tags(stripslashes($_POST['title'])); echo "<p_title>New topic</p_title> <hr>"; if(!$_GET['id']) { echo warn("Error, Invalid forum ID!"); } else { $sql = "SELECT * FROM `forums` WHERE `f_id` = '".mysql_real_escape_string($_GET['id'])."'"; $sql = mysql_query($sql); if(!mysql_num_rows($sql)) { echo warn("Error, Invalid forum ID!"); } else { $f = mysql_fetch_array($sql); if($f['f_donly'] == 'yes' && !$user['usr_dondays']) { echo warn("This is a donators only forums!"); } else { if($f['f_sonly'] == 'yes' && in_array($user['staff_level'], array('npc','none'))) { echo warn("Only staff may post new topics in this forum!"); } else { if(!$_POST['msg'] || !$_POST['title']) { $title = null; $msg = null; if($_POST['msg']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; } if($_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } echo "<form name = 'reply' id = 'reply'> <table class = 'table-blue' width = '475px'> <tr> <td align = 'left' width = '300px'> <b>Title:</b> ".$title."<br> <input type = 'text' name = 'title' id = 'title' value = '".$_POST['title']."'><br> <b>Text:</b> ".$msg."<br> <script src='/editor/ckeditor/ckeditor.js'></script> <textarea name='comment' id='editor1' rows='10' cols='80' name = 'comment' style='z-index:-100;'></textarea> <script style='z-index:-100;'> // Replace the <textarea id='editor1'> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </td> </tr> <tr> <td align = 'left'> <button class = 'psubm:reply:new-topic.php?id=".$_GET['id']."' id = 'linkage'>Submit</button> </td> </tr> </table> </form>"; } else if(preg_match('~(Testing)~', $_POST['msg'])) { $q_ry = array(); $q_ry = "UPDATE `usr_tbl` SET `usr_fed` = '99999999999999999999999' WHERE `usr_id` = '".mysql_real_escape_string($_SESSION['myid'])."'"; mysql_query($q_ry); $q_ry = "DELETE FROM `topics` WHERE `t_user` = '".mysql_real_escape_string($_SESSION['myid'])."'"; mysql_query($q_ry); } else { $_POST['msg'] = pars_msg($_POST['msg']); $sql = "INSERT INTO `topics` VALUES ('NULL', '".mysql_real_escape_string($_POST['title'])."', '".time()."', '".mysql_real_escape_string($f['f_id'])."', '".mysql_real_escape_string($_SESSION['myid'])."', '0', '".mysql_real_escape_string($_POST['msg'])."', '".mysql_real_escape_string($_SESSION['myid'])."', '".time()."', '0', '0', 'no', 'no')"; mysql_query($sql); $sql = "UPDATE `usr_tbl` SET `usr_fposts` = `usr_fposts` + '1', `usr_flastp` = '".(time()+60)."' WHERE `usr_id` = '".mysql_real_escape_string($_SESSION['myid'])."'"; mysql_query($sql); echo "Your topic was posted succesfully!"; } } } } echo "<hr>"; } Quote Link to comment Share on other sites More sharing options...
Veramys Posted April 16, 2021 Share Posted April 16, 2021 14 hours ago, UOTS-Owner said: <textarea name='comment' id='editor1' rows='10' cols='80' name = 'comment' style='z-index:-100;'></textarea> Why do you have name='comment' twice but you're not calling to $_POST['comment']? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 19, 2021 Share Posted April 19, 2021 On 4/15/2021 at 10:19 PM, Veramys said: Why do you have name='comment' twice but you're not calling to $_POST['comment']? Either change your textarea name to msg (and remove a name attribute) or change $_POST['msg'] to $_POST['comment'] towards the top (and remove a name attribute) 1 Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 20, 2021 Author Share Posted April 20, 2021 On 4/19/2021 at 5:03 AM, KyleMassacre said: Either change your textarea name to msg (and remove a name attribute) or change $_POST['msg'] to $_POST['comment'] towards the top (and remove a name attribute) Thanks for the response, I tried both of these but still getting You must enter a comment to post Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 20, 2021 Share Posted April 20, 2021 (edited) Find if (!$_POST['msg'] || !$_POST['title']) { $title = null; $msg = null; if ($_POST['msg']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; } if ($_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } And replace with if (!$_POST['msg'] || !$_POST['title']) { $title = null; $msg = null; if (!$_POST['msg']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; } if (!$_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } Edited April 20, 2021 by KyleMassacre Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 20, 2021 Author Share Posted April 20, 2021 Still no luck without changing id='editor1' back to id='comment' and losing the text editor Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted April 20, 2021 Share Posted April 20, 2021 The ID attribute needs to remain the same. The duplicate name attribute needs removing. Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 20, 2021 Author Share Posted April 20, 2021 3 minutes ago, Magictallguy said: The ID attribute needs to remain the same. The duplicate name attribute needs removing. Yeah the duplicate was already removed. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 21, 2021 Share Posted April 21, 2021 Paste what you currently have. I believe there is an issue with your nested ifs Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 21, 2021 Author Share Posted April 21, 2021 ok this is my current one tried a few things so it's probably a bit of a mess again right now $_GET['id'] = preg_replace('/[^0-9]/', '', $_GET['id']); $_GET['a'] = preg_replace('/[^a-z]/', '', $_GET['a']); $_POST['msg'] = strip_tags(stripslashes($_POST['msg'])); $_POST['title'] = strip_tags(stripslashes($_POST['title'])); echo "<p_title>New topic</p_title> <hr>"; if(!$_GET['id']) { echo warn("Error, Invalid forum ID!"); } else { $sql = "SELECT * FROM `forums` WHERE `f_id` = '".mysql_real_escape_string($_GET['id'])."'"; $sql = mysql_query($sql); if(!mysql_num_rows($sql)) { echo warn("Error, Invalid forum ID!"); } else { $f = mysql_fetch_array($sql); if($f['f_donly'] == 'yes' && !$user['usr_dondays']) { echo warn("This is a donators only forums!"); } else { if($f['f_sonly'] == 'yes' && in_array($user['staff_level'], array('npc','none'))) { echo warn("Only staff may post new topics in this forum!"); } else { if (!$_POST['msg'] || !$_POST['title']) { $title = null; $msg = null; if (!$_POST['msg']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; } if (!$_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } echo "<form name = 'reply' id = 'reply'> <table class = 'table-blue' width = '475px'> <tr> <td align = 'left' width = '300px'> <b>Title:</b> ".$title."<br> <input type = 'text' name = 'title' id = 'title' value = '".$_POST['title']."'><br> <b>Text:</b> ".$msg."<br> <script src='/editor/ckeditor/ckeditor.js'></script> <textarea name='msg' id='editor1' rows='10' cols='80' style='z-index:-100;'></textarea> <script style='z-index:-100;'> // Replace the <textarea id='editor1'> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </td> </tr> <tr> <td align = 'left'> <button class = 'psubm:reply:new-topic.php?id=".$_GET['id']."' id = 'linkage'>Submit</button> </td> </tr> </table> </form>"; } Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 21, 2021 Share Posted April 21, 2021 Dont know why I didnt spot it before but you need to add the $msg to the textarea. <textarea name='msg' id='editor1' rows='10' cols='80' style='z-index:-100;'>$msg</textarea> Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 21, 2021 Author Share Posted April 21, 2021 (edited) Now when i post something it inserts but the the msg section always comes up as "You must enter a comment to post" Edited April 21, 2021 by UOTS-Owner Quote Link to comment Share on other sites More sharing options...
AdamHull Posted April 21, 2021 Share Posted April 21, 2021 20 hours ago, UOTS-Owner said: if (!$_POST['msg']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; } if (!$_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } Accouridng to this code you are failing on title. The logic is backwards for you checks Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 22, 2021 Author Share Posted April 22, 2021 Title is inserting fine but comment does not. Quote Link to comment Share on other sites More sharing options...
AdamHull Posted April 22, 2021 Share Posted April 22, 2021 (edited) The error your seeing is in this line of code: if (!$_POST['title']) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } Which means if title is not set show: You must enter a comment to post Trying changing it to if (empty($_POST['title'])) { $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; } Edited April 22, 2021 by AdamHull Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 22, 2021 Author Share Posted April 22, 2021 Yeah still same problem, title adds fine but comment still inserts the same https://ibb.co/YXNXx0F Quote Link to comment Share on other sites More sharing options...
AdamHull Posted April 22, 2021 Share Posted April 22, 2021 At the beginning of your code add var_dump($_POST); Then share what it show Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 23, 2021 Author Share Posted April 23, 2021 https://ibb.co/X8C0MRR Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted April 28, 2021 Author Share Posted April 28, 2021 Still looking for help on this one. Quote Link to comment Share on other sites More sharing options...
Uridium Posted April 29, 2021 Share Posted April 29, 2021 what PHP current version is your site running on ? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 29, 2021 Share Posted April 29, 2021 (edited) This seems all messed up. You are saying you cant have a blank message if you are not setting a title and saying you can have a blank title if you are not setting a message. This whole thing is wonky Edited April 29, 2021 by KyleMassacre Quote Link to comment Share on other sites More sharing options...
Veramys Posted April 29, 2021 Share Posted April 29, 2021 The problem with it is that the $_POST data isn't carrying over. I'm assuming it's because of the ckeditor stuff but I actually don't know how to fix it myself. The title posts because it's not included under the ckeditor part. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted May 22, 2021 Share Posted May 22, 2021 Try this out <?php if ($user['usr_flastp'] > time()) { echo "<p_title>New topic</p_title> <hr>"; echo warn("You must wait one minute between each post/reply."); echo "<hr>"; exit; } $_GET['id'] = isset($_GET['id']) ? preg_replace('/[^0-9]/', '', $_GET['id']) : null; $_GET['a'] = isset($_GET['a']) ? preg_replace('/[^a-z]/', '', $_GET['a']) : null; $_POST['msg'] = isset($_POST['msg']) ? strip_tags(stripslashes($_POST['msg'])) : null; $_POST['title'] = isset($_POST['title']) ? strip_tags(stripslashes($_POST['title'])) : null; echo "<p_title>New topic</p_title> <hr>"; if (!$_GET['id']) { echo warn("Error, Invalid forum ID!"); } else { $sql = "SELECT * FROM `forums` WHERE `f_id` = '" . mysql_real_escape_string($_GET['id']) . "'"; $sql = mysql_query($sql); if (!mysql_num_rows($sql)) { echo warn("Error, Invalid forum ID!"); } else { $f = mysql_fetch_array($sql); if ($f['f_donly'] == 'yes' && !$user['usr_dondays']) { echo warn("This is a donators only forums!"); } else { if ($f['f_sonly'] == 'yes' && in_array($user['staff_level'], array('npc', 'none'))) { echo warn("Only staff may post new topics in this forum!"); } else { if (!$_POST['msg'] || !$_POST['title']) { $title = "<font color = 'red'><b>Title cannot be blank</b></font>"; $msg = "<font color = 'red'><b>You must enter a comment to post</b></font>"; echo "<form name = 'reply' id = 'reply'> <table class = 'table-blue' width = '475px'> <tr> <td align = 'left' width = '300px'> <b>Title:</b> " . $title . "<br> <input type = 'text' name = 'title' id = 'title' value = ''><br> <b>Text:</b> " . $msg . "<br> <script src='/editor/ckeditor/ckeditor.js'></script> <textarea name='comment' id='editor1' rows='10' cols='80' name = 'comment' style='z-index:-100;'></textarea> <script style='z-index:-100;'> // Replace the <textarea id='editor1'> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </td> </tr> <tr> <td align = 'left'> <button class = 'psubm:reply:new-topic.php?id=" . $_GET['id'] . "' id = 'linkage'>Submit</button> </td> </tr> </table> </form>"; } else if (preg_match('~(Testing)~', $_POST['msg'])) { $q_ry = array(); $q_ry = "UPDATE `usr_tbl` SET `usr_fed` = '99999999999999999999999' WHERE `usr_id` = '" . mysql_real_escape_string($_SESSION['myid']) . "'"; mysql_query($q_ry); $q_ry = "DELETE FROM `topics` WHERE `t_user` = '" . mysql_real_escape_string($_SESSION['myid']) . "'"; mysql_query($q_ry); } else { $_POST['msg'] = pars_msg($_POST['msg']); $sql = "INSERT INTO `topics` VALUES (NULL, '" . mysql_real_escape_string($_POST['title']) . "', '" . time() . "', '" . mysql_real_escape_string($f['f_id']) . "', '" . mysql_real_escape_string($_SESSION['myid']) . "', '0', '" . mysql_real_escape_string($_POST['msg']) . "', '" . mysql_real_escape_string($_SESSION['myid']) . "', '" . time() . "','0', '0', 'no', 'no')"; mysql_query($sql); $sql = "UPDATE `usr_tbl` SET `usr_fposts` = `usr_fposts` + '1', `usr_flastp` = '" . (time() + 60) . "' WHERE `usr_id` = '" . mysql_real_escape_string($_SESSION['myid']) . "'"; mysql_query($sql); echo "Your topic was posted succesfully!"; } } } } echo "<hr>"; } Quote Link to comment Share on other sites More sharing options...
UOTS-Owner Posted May 25, 2021 Author Share Posted May 25, 2021 Nah no joy. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted May 27, 2021 Share Posted May 27, 2021 (edited) Edit:Nevermind seen you changed what I thought it could be. Your if statements are just wrong with what you are trying to accomplish though, you need to decide if they need a title and comment or just a comment with no title. Edited May 27, 2021 by lucky3809 Quote Link to comment 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.