0

I'm trying to input into mysql database through a php form. But it doesn't get inserted when i'm using space. I'm trying to use single quote around table's attribute's name. Still doesn't help!

<!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" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>rankO - notice</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
  <h2>Notice Board</h2>
  <?php
    $headline = $_POST['headline'];
 $details = $_POST['details'];
 if(isset($_POST['update'])){
  echo $headline;
  echo $details;
  $dbc = mysqli_connect('localhost', 'root', '', 'rankodatabase');
  $query1 = "INSERT INTO notice (datetime, 'headline', 'details')VALUES (NOW(), '$headline', '$details')";
  mysqli_query($dbc, $query1);
  mysqli_close($dbc);
 }
    if(!isset($_POST['update'])){
  ?>
  <form action = "<?php echo $SERVER['PHP_SELF'];?>" method = "post">
    <table>
    <tr>
      <th>Headline:</th>
   <td>
     <input type = "text" name = "headline" />
   </td>
    </tr>
    <tr>
      <th>Details:</th>
   <td>
     <textarea name = "details" rows = "20" cols = "60"></textarea>
   </td>
    </tr>
    <tr>
      <th></th>
   <td>
     <input type = "submit" name = "update" value = "update" />
   </td>
    </tr>
  </table>
  </form>
  <?php
 }
  ?>
</body>
</html>

I'd really appreciate your help. Thank you!

0 Answers0