suyati / line-control

A Light Weight HTML5 Text Editor designed as a JQuery Plugin
Other
124 stars 90 forks source link

how to save the text edited in the textarea to my sql database #81

Closed trace-me closed 7 years ago

trace-me commented 7 years ago

my code is the following:

<form action="<?php ($_SERVER["PHP_SELF"]);?>" method="post">

        <div>
             <label for="txtEditor">Notitie:</label>
             <textarea class="form-control" id="txtEditor" name="txtEditor" ></textarea> 
        </div>
        <br>
        <button type="submit" name="submit" class="btn btn-success"><i class="fa fa-check" aria-hidden="true"></i> Toevoegen</button>
    </form>
</p>

<?php

$title = $_POST["title"]; $note = $_POST["note"];

if ($_SERVER['REQUEST_METHOD'] == "POST"){
    include '../database/connector.php';
            $conn = new mysqli($db_servername, $db_username, $db_password, $db_name);

            // Check connection
            if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            }

            $sql = "INSERT INTO notities (title, note, gebruiker, date)
            VALUES ('$title', '$note', '$user_id', '$date_today')";

            if ($conn->query($sql) === TRUE) {
                echo "";
            } else {
                echo "Error: " . $sql . "<br>" . $conn->error;
            }

            $conn->close();

}

?>

but can't save to my sql database. things although title is saved