Jump to content
MakeWebGames

help with ckeditor


UOTS-Owner
 Share

Recommended Posts

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>";
}

 

Link to comment
Share on other sites

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']?

Link to comment
Share on other sites

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)
 

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by KyleMassacre
Link to comment
Share on other sites

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>";
                        }

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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 by AdamHull
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 weeks later...

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>";
}

 

Link to comment
Share on other sites

Posted (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 by lucky3809
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...