0

Hi, I just downloaded TinyMCE WYSIWYG, and I am doing an insert query into MySQL using PHP.
Everytime I submit the form it returns false. and if I toke out the textarea everything goes ok.
I am pretty sure it's TinyMCE. Have any of you came across this problem, am I missing something?
The code works fine when I load the page, TineMCE looks good, but when I submit the form it simply fails.
Please advise,
and thank you in advance
FarrisFahad

3
Contributors
8
Replies
27
Views
4 Years
Discussion Span
Last Post by FarrisFahad
0

I don't have any experience with TinyMCE, but I looked into it when choosing an editor to go with for DaniWeb. Can you post your code and I'll take a look at it?

So you're saying everything works fine if you replace TinyMCE with a standard textbox, but not with TinyMCE??

What do you mean that the form returns false. How can an HTML form return false? What exactly is failing? Is the form being submitted but just the record isn't being entered into MySQL??

The way that these Javascript-based WYSIWYG editors work is the area you're typing in isn't really the textbox that's being submitted as part of the form. Upon hitting the submit button, Javascript magic takes over and puts everything in the WYSIWYG editor into the actual textbox to be submitted. At least that's been my experience with the ones I've worked with.

0

Hi Dani,
Here is the code

I have replaced some values and variables to numbers ...

<?php

    require_once("../Includes/Con.php");

    $1 = $_SESSION["user_id"];
    $2 = $_GET["id"];
    $3 = mysql_real_escape_string($_POST["title"]);
    $4 = $_POST["text"];
    $5 = strftime("%y-%m-%d", time());

    if(!empty($3) && !empty($4)){
        if(mysql_query("INSERT INTO updates (1, 2, 3, 4, 5) VALUES ('{$1}','{$2}','{$3}', '{$4}', '{$5}')")){
            header("Location: ../First.php?id={$id}");
            exit;
        }else{
            $_SESSION["ERROR_UPDATE"] = "There was an error, please try again later.";
            header("Location: ../Second.php");
            exit;
        }
    }else{
        $_SESSION["EMPTY_UPDATE_BOX"] = "Please fill in the fields";
        header("Location: ../Third.php?id={$id}");
        exit;
    }

?>

Note that when I press the submit button in the form page which leads to hear the PHP will take you to Second.php, which is fail. I want it to instead go to First.php. But it seems like there is something wrong with the WYSIWYG. Any Ideas ...

0

Well it's good that it's not taking you to Third.php, because at least the title and body of the post are being posted by the form. Try enclosing $_POST['text'] with mysql_real_escape_string() the same way you are doing with the post title.

0

I have never had problems with my frameworks with TinyMCE.
In this case I was using Codeigniter

84ead468266664e43febab31ad2225b0

Add to your javascript this mode : "textareas"

Than the saving to the DB

    public function creaza_anunt() {
        $new_anunt_insert = array(
            "poster"    =>  $this->session->userdata('poster'),
            "title"     =>  ucfirst($this->input->post('title')),
            "keywords"  =>  $this->input->post('keywords'),
            "content"   =>  ucfirst($this->input->post('content')),
            "meta_title"=>  $this->seofy($this->input->post('title'))
        );

        $insert = $this->db->insert('anunturi', $new_anunt_insert);
        return $insert;
    }

Also please post your FORM source code

And after submiting your form write this on the top of your submited page.

echo '<pre>';
print_r($_REQUEST);

And show us your results please

Edited by Szabi Zsoldos

0

this is the tinymce code ...

<script type="text/javascript" src="tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    selector: "textarea"
 });
</script>



<form id="form1" name="form1" method="post" action="Fourth.php?id=<?php echo $fetch["2"]; ?>">
          <table width="680" border="0" cellspacing="3" cellpadding="3">
            <tr>
              <td colspan="2">Update Thread:</td>
            </tr>
            <tr>
              <td width="90">Title:</td>
              <td width="569"><label for="textfield"></label>
              <input type="text" name="title" id="Title" /></td>
            </tr>
            <tr>
              <td colspan="2" align="center">Update</td>
            </tr>
            <tr>
              <td colspan="2"><label for="textarea"></label>
              <textarea name="text" id="textarea" cols="45" rows="5">
0
  1. Do you close your form ?
  2. Did you try the

    print_r($_POST);

    or

    print_r($_REQUEST);

    ?

Edited by Szabi Zsoldos

1

I have solved the problem, I named one of the MySQL Colums update which was making a problem :) . I renamed the Colums from update to update_something and it worked, Yay :)

Thank you guys for your help :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.