Hi,
I have the following which is working just fine atm.
in view
controller
model
jquery
Now all this works fine in what it is doing, but I am trying to add an email input, I modified as below but it just breaks it but I get no errors from anywhere, if I add the title or description to the email one is works, it just breaks as soon as I add email to the model in the $_POST['email'] part.
model new
jquery new
view new
I have tried both input types for it as email and text, also in the database I have tried VARCHAR and TEXT.
I just cannot see what I have done wrong for it to go through and throw up no errors but yet it just does not throw it into the database, I change just $_POST['email'] to $_POST['title'] say and it works
Doomie
I have the following which is working just fine atm.
in view
Code:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<div class="error"></div>
<form class="form-horizontal" id="crud-form">
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Customer Name</label>
<div class="col-md-8">
<input type="text" class="form-control" name="title" value="" id="title">
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Information</label>
<div class="col-md-8">
<textarea class="form-control" id="description" name="description"></textarea>
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Start Date</label>
<div class="col-md-8">
<input type="text" class="form-control datePick" name="start" id="start" readonly>
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">End Date</label>
<div class="col-md-8">
<input type="text" class="form-control datePick" name="end" id="end" readonly>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="color">Color</label>
<div class="col-md-8">
<input id="color" name="color" type="text" class="form-control input-md" readonly="readonly" />
<span class="help-block">Click to pick a color</span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>controller
PHP Code:
Public function addEvent() {
$result = $this->Newcal_model->addEvent();
echo $result;
}
model
PHP Code:
Public function addEvent()
{
$sql = "INSERT INTO events (title,events.start,events.end,description, color) VALUES (?,?,?,?,?)";
$this->db->query($sql, array($_POST['title'], $_POST['start'],$_POST['end'], $_POST['description'], $_POST['color']));
return ($this->db->affected_rows()!=1)?false:true;
}
jquery
Code:
// Handle Click on Add Button
$('.modal').on('click', '#add-event', function(e){
if(validator(['title', 'description'])) {
$.post(base_url+'newcal/addEvent', {
title: $('#title').val(),
description: $('#description').val(),
color: $('#color').val(),
start: $('#start').val(),
end: $('#end').val()
}, function(result){
$('.alert').addClass('alert-success').text('Event added successfuly');
$('.modal').modal('hide');
$('#calendar').fullCalendar("refetchEvents");
hide_notify();
});
}
});Now all this works fine in what it is doing, but I am trying to add an email input, I modified as below but it just breaks it but I get no errors from anywhere, if I add the title or description to the email one is works, it just breaks as soon as I add email to the model in the $_POST['email'] part.
model new
PHP Code:
Public function addEvent()
{
$sql = "INSERT INTO events (title,email,events.start,events.end,description, color) VALUES (?,?,?,?,?,?)";
$this->db->query($sql, array($_POST['title'],$_POST['email'], $_POST['start'],$_POST['end'], $_POST['description'], $_POST['color']));
return ($this->db->affected_rows()!=1)?false:true;
}
jquery new
Code:
$('.modal').on('click', '#add-event', function(e){
if(validator(['title', 'description'])) {
$.post(base_url+'newcal/addEvent', {
title: $('#title').val(),
email: $('#email').val(),
description: $('#description').val(),
color: $('#color').val(),
start: $('#start').val(),
end: $('#end').val()
}, function(result){
$('.alert').addClass('alert-success').text('Event added successfuly');
$('.modal').modal('hide');
$('#calendar').fullCalendar("refetchEvents");
hide_notify();
});
}
});view new
Code:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<div class="error"></div>
<form class="form-horizontal" id="crud-form">
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Customer Name</label>
<div class="col-md-8">
<input type="text" class="form-control" name="title" value="" id="title">
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Customer Email</label>
<div class="col-md-8">
<input type="email" class="form-control" name="email" value="" id="email">
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Information</label>
<div class="col-md-8">
<textarea class="form-control" id="description" name="description"></textarea>
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">Start Date</label>
<div class="col-md-8">
<input type="text" class="form-control datePick" name="start" id="start" readonly>
</div>
</div>
<div class="form-group">
<label for="p-in" class="col-md-4 label-heading">End Date</label>
<div class="col-md-8">
<input type="text" class="form-control datePick" name="end" id="end" readonly>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="color">Color</label>
<div class="col-md-8">
<input id="color" name="color" type="text" class="form-control input-md" readonly="readonly" />
<span class="help-block">Click to pick a color</span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>I have tried both input types for it as email and text, also in the database I have tried VARCHAR and TEXT.
I just cannot see what I have done wrong for it to go through and throw up no errors but yet it just does not throw it into the database, I change just $_POST['email'] to $_POST['title'] say and it works
Doomie