Home>

I want to achieve
Currently, I am making a calendar application, as it is in the subject, but when you press the date I want to register the schedule, a modal window appears, write the contents there, and press the save button to send the contents to the DB I want to

Previously, I switched to another screen, typed the contents there and sent it to the DB, I thought that it would be possible to follow the procedure in the same way, but I am having trouble and I am in trouble.

I would appreciate it if you could teach me.

Source code

<?php
 require('dbconnect.php');
 session_start();
 try {
    if (!empty($_POST)) {
      if ($_POST['message'] !=='') {
        $content = $db->prepare('INSERT INTO posts(user_id,content) values(?,?)');
        $content->execute(array(
          $_SESSION['id'],
          $_POST['message']
        ));
        header('Location: index.php');
        exit();
      }
    }
  }catch(Exception $e){
    echo $e->getMessage();
    echo $e->getTraceAsString();
    die();
  }
 ?>
<!-- 2. Modal placement -->
  
    
    
    <!-- 3. Modal content -->
        
      <!-- 4. Modal header -->
        
        <button type="button" data-dismiss="modal">
          <span aria-hidden="true">&times;</span>
        </button>
          Register
        
      <!-- 5. Modal body -->
      <form action="" method="post">
        
        <p>Title</p>
          <input type='text' name='title'>
        <p>Planned content<br>
          <textarea name='message' cols='70' rows='5' ></textarea><!-- This is the content!-->
        </p>
        
      <!-- 6. Modal footer -->
        
        <button type="button" data-dismiss="modal">Close</button>
        <button type="button">Save</button>
        
      </form>
      
    

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

What I tried
There is no error, and even if you press the save button, the modal window is displayed and nothing changes.

capture
Development environment
OS: Mac
Web server: xampp
DB:mysql