GeekBoi GeekBoi - 2 months ago 35
SQL Question

Bootstrap modal form submit not working

please i need someone to help me check if i'm missing something. The form in the Bootstrap modal wont submit.

my HTML codes for the modal (sidebar.php)

<!-- start Joel's modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">E-Logbook Entry</h4>
<div class="modal-body">
<form id="modal-form" method="post" action="notes_functions.php">
<label>Log Entry</label>
<textarea rows="4" cols="50" class="form-control" name="note_content" placeholder="What have you learnt today?..."></textarea>
<div class = "modal-footer">
<button type = "button" class = "btn btn-default" data-dismiss = "modal">
<input type="submit" name="submit" class="btn btn-default" id="submitnote" value="Submit" />
<!-- end Joel's modal -->

codes for the PHP file (notes_functions.php)

include_once 'database-config.php';

if (isset($_POST['submitnote'])) {

$noteContent = strip_tags($_POST['note_content']);

$sql = "INSERT INTO account_notes (note_contents) VALUES ('$noteContent')";
echo "New record created successfully";
echo "Log details = ".$note_contents;

my AJAX codes for submitting the form

<script type="text/javascript">
var frm = $('#modal-form');
frm.submit(function (ev) {
type: frm.attr('method'),
url: frm.attr('action'),
dataType: "JSON",
data: frm.serialize(),
success: function (data) {


I can't seem to spot the error :-(


Two things:-

1.Instead of if (isset($_POST['submitnote'])) { use if (isset($_POST['submit'])) {

2.Put ev.preventDefault(); before $.ajax({