Web Analytics Made Easy -
StatCounter JS/PHP textarea not working - CodingForum

Announcement

Collapse
No announcement yet.

JS/PHP textarea not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JS/PHP textarea not working

    I don't know how to even tell you what the problem is

    I'm attempting to use a js wysiwyg text editor on my form...the form won't submit if all the fields aren't filled in and I think it's not recognizing the wysiwyg

    I'd post code but I'm not sure what you need...

  • #2
    Start by posting your form code. Someone can look at it to see what you are doing and/or try it to see what it is or is not doing.

    You are probably using the POST method on the form, put the following in to your action= processing .php file to display what is actually being submitted -
    PHP Code:
    echo "<pre>";
    print_r($_POST);
    echo 
    "</pre>"
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

    Comment


    • #3
      I used the <pre> and it displayed data in all the fields

      form code:

      Code:
      <form action="<? echo $_SESSION['PHP_SELF'] ?>" method="post">
      	<p>
      	<label for="author">Author:  </label>
      	<input type="text" size="40" name="PostAuthor"  value="<? echo (isset($_POST['PostAuthor'])) ? $_POST['PostAuthor'] : ''; ?>" />
      	</p>
      	<p>
      	<label for="title">Title:  </label>
      	<input type="text" size="40" name="PostTitle" value="<? echo (isset($_POST['PostTitle'])) ? $_POST['PostTitle'] : ''; ?>" />
      	</p>
      	<p>
      	<textarea id="msgarea" name="PostComment" rows="15" cols="45" value="<? echo (isset($_POST['PostComment'])) ? $_POST['PostComment'] : ''; ?>"></textarea>
          <script type="text/javascript">
            generate_wysiwyg('msgarea');
          </script>
      	</p>
      	<p>
      	<input type="submit" name="add" value="Add Comment" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="reset" value="Start Over" />
      	</p>
      	</form>
      the php code is:
      PHP Code:
              $author=$_POST['PostAuthor'];
              
      $title=$_POST['PostTitle'];
              
      $content=$_POST['PostContent'];
              
      $error=array();

              if (isset(
      $_POST['add']))
                  {

                      if (
      strlen(trim($_POST['PostAuthor']))==0)
                      {
                      
      $error['author'] = 'Please enter your name.';
                      }
                  
                      if (
      strlen(trim($_POST['PostTitle']))==0)
                      {
                      
      $error['title'] = 'Please enter a title.';
                      }

                      if (
      strlen(trim($_POST['PostContent']))==0)
                      {
                      
      $error['content'] = 'Please enter a comment.';
                      }

                      if (
      count($error)==0)
                      {
                      
      $query="INSERT INTO tblSCIBlog (PostDate, PostAuthor, PostTitle, PostContent) VALUES (CURRENT_DATE(), '$author', '$title', '$content')";
                      
      $result=mysql_query($query);
                      
                          if(
      $result)
                          {
                          echo 
      "<p style=\"color:#ff0000;font-weight:bold;font-size:14px;\">Your blog entry has been submitted.</p>";
                          }
                          
      mysql_close($conn);
                      }

                  else
                      {
                      foreach(
      $error as $err)
                          {
                          echo 
      "<p style=\"color:#ff0000;font-weight:bold;font-size:14px;\">" $err "</p>";
                          }
                      }

                  } 
      Last edited by harlequin2k5; Oct 15, 2006, 12:19 AM.

      Comment


      • #4
        Resolved

        n/m I'm using the wrong variable again

        these variables are going to kill me!

        using PostComment instead of PostContent

        Comment


        • #5
          Edit: Took me a while to test... and type. I see you found it.

          I see one problem right away - the following:

          $_SESSION['PHP_SELF'] should probably be $_SERVER['PHP_SELF']

          However, it evaluates to a null/empty and results in an action="" which submits back to the same file anyway.

          It tried your code (less the javascript) and here is where the most obvious problem is -

          The content field on the form has the name - PostComment
          However, the $_POST variable has the name - PostContent
          Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

          Comment

          Working...
          X