Showing posts with label ckeditor textarea value. Show all posts
Showing posts with label ckeditor textarea value. Show all posts

Thursday, 17 July 2014

ckeditor text input insert into database full source code

 AAVIK KUMAR PRODUCTION






This tutorial will teach how "CkEditor text input" get stored in mysql or other database.Here is full code for CkEditor textarea input insert or stored  into database.


http://www.elated.com/articles/adding-wysiwyg-editor-to-your-site/

HERE IS THE SCRIPT :-
ckeditor_file_structure how to add ckeditor in website

1.button2 is submit button.
2.qpaper is table name.
3.uploadtext >>>>>$_POST[editor1]
4.<textarea class="ckeditor" cols="20" id="editor1" name="editor1" rows="10"></textarea>

THIS IS THE CODE FOR UPLOADING TEXTAREA FIELD of ckeditor
---------------------------------------------------------------------
    <script type="text/javascript" src="editor/ckeditor.js"></script>
    <script src="editor/_samples/sample.js" type="text/javascript"></script>
    <link href="editor/_samples/sample.css" rel="stylesheet" type="text/css" />
<?php
include("mysql.php");
if(isset($_POST["button2"]))
{
$sql="INSERT INTO qpaper (papername,subject,section,description,upload,uploadtext)
VALUES
('$_POST[textfield]','$_POST[select]','$_POST[select2]',
'$_POST[textarea]','$_POST[fileField]','$_POST[editor1]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
  else
  {
echo "Question paper uploaded Successfully";
  }

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Question Paper page</title>
</head>

<body>
<form id="form1" name="form1"  method="post" action="Qpaper.php">
<table width="958" height="372">
  <tr>
    <td width="69">Paper Name:</td>
    <td width="608"><input name="textfield" type="text" id="textfield" size="40" /></td>
  </tr>
  <tr>
    <td>Section:</td>
    <td><select name="select" id="select">
    </select></td>
  </tr>
  <tr>
    <td>Subject:</td>
    <td><select name="select2" id="select2">
    </select></td>
  </tr>
  <tr>
    <td height="53">Description</td>
    <td><textarea name="textarea" id="textarea" cols="45" rows="3"></textarea></td>
  </tr>
  <tr>
    <td>Upload</td>
    <td>
      <label for="fileField"></label>
      <input name="fileField" type="file" id="fileField" size="40" />
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <label for="textarea2"></label>
      <textarea class="ckeditor" cols="20" id="editor1" name="editor1" rows="10"></textarea>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="submit" name="button2" id="button2" value="Upload Question Paper" />
    </td>
  </tr>
</table></form>
</body>
</html>


--------------------------------------------------------------------------------
 2nd example
--------------------------------------------------------------------------------
 Three files home.php,add.php,mysql.php

cktext table file for database ckeditor

home.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <title>Test Page </title >
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/ >
  <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>

<form id="form1" name="form1" method="post" action="add.php">
<table width="958" height="372">
  <tr>
    <td width="69">Name:</td>
    <td width="608"><input name="textfield" type="text" id="textfield" size="40" /></td>
  </tr>


<tr>
    <td width="69">Email:</td>
    <td width="608"><input name="te" type="text" id="te" size="40" /></td>
  </tr>


  <tr>
    <td>Section:</td>
    <td><select name="select" id="select">
    </select></td>
  </tr>
  <tr>
    <td>Subject:</td>
    <td><select name="select2" id="select2">
    </select></td>
  </tr>
  <tr>
    <td height="53">Description</td>
    <td><textarea name="textarea" id="textarea" cols="45" rows="3"></textarea></td>
  </tr>
  <tr>
    <td>Upload</td>
    <td>
      <label for="fileField"></label>
      <input name="fileField" type="file" id="fileField" size="40" />
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <label for="textarea2"></label>
      <textarea class="ckeditor" cols="20" id="editor1" name="editor1" rows="10"></textarea>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="submit" name="button2" id="button2" value="Upload" />
    </td>
  </tr>
</table>

</form>
</body>
</html>


add.php




<?php
include("mysql.php");

if(isset($_POST["button2"]))
{
$sql="INSERT INTO cktext (papername,subject,section,description,upload,uploadtext)
VALUES
('$_POST[textfield]','$_POST[select]','$_POST[select2]',
'$_POST[textarea]','$_POST[fileField]','$_POST[editor1]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
  else
  {
echo "Question paper uploaded Successfully</br> YOUR TEXT IS";
}//else

 }//first if isset
?>


mysql.php

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("ckeditor",$con);
?>


DOWNLOAD FULL SOURCE CODE