0

What's the problem in this code?
It shows no error while querying, neither does it get stored

<?php
if(isset($_POST['submit']))
{
$title=$_POST['title'];
$content=$_POST['content'];

$dbc=mysqli_connect('localhost','root','root','skype')
or die('Error connecting');
$query= "INSERT INTO pages (title,editor) VALUES ('$title', '$content')" 
 or die('Error querying database');
echo '<br>Page saved successfully under the title: '.$title.'<br>';
mysqli_close($dbc);
 }

 ? >
 <form>
  <label for="title">Title</label>
  <input type="text" name="title" required >
  <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
    <textarea class="ckeditor" name="content" ></textarea>
   <input type="submit" name="submit" value="Submit">
  </form>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Piyush Rawat
  • 135
  • 9
  • I have no mercy for ones flooding SO with super-low-quality questions like this one and http://stackoverflow.com/questions/29471532/no-output-from-database-using-ckeditor. You should read http://stackoverflow.com/help/how-to-ask – Reinmar Apr 06 '15 at 16:17

1 Answers1

0

The default request method for a form is GET (see specs). If you want to POST your form you need to explicitly add the method:

<form method="post">

Otherwise your $_POST will always be empty.

Also, you are open to SQL injection.

Community
  • 1
  • 1
TiiJ7
  • 3,332
  • 5
  • 25
  • 37