I'm struggling to finish a final piece of my project - I have a textbox that is populated by a date time picker in the format YYYY/MM/DD HH:MM
I need to pass this value in to a URL string, which is then sent to a database table.
As I''m using a modal to gather the additional information I need I have a Jquery script to alter my HREF tab on the submit button:
$(document).on('click','#myModal<?php echo $v['id']; ?> .modal-footer a', function(e)
{
e.preventDefault();
//function to update HREf attribute with values from modal screen
var uri = <?php urlencode('2016/01/01/ 21:00')?>
//$('#divert_until_<?php echo $v['id']; ?>').text();
window.location.href=window.location.href= $(this).attr('href') + '&to=' + $('#divert_to_<?php echo $v['id']; ?> option:selected').text() + '&type= ' + $('#divert_type_<?php echo $v['id']; ?> option:selected').text() + '&until= ' + uri;
});
Currently, I receive all the information (ID, TO, and TYPE) but nothing from UNTIL. Above I am trying to save the fixed string '2016/01/01 21:00' to the database.
Here is my code to catch the URL:
if(isset($_GET['action']) && $_GET['action']=='add_divert') {
if(!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$_SESSION['notification'] = array('type'=>'bad','msg'=>$lang['ADMIN_INVALID_ID']);
redirect(ROOT_URL.'stores.php?search='.$_REQUEST['search'].$pg.$st.$fl);
}
$db = db_connect();
if($db->update('stores',array('divert_enabled'=>1,'divert_type'=>($_GET['type']),'divert_until'=>($_GET['until']),'divert_to'=>($_GET['to'])),$_GET['id'])) {
$_SESSION['notification'] = array('type'=>'good','msg'=>'Divert notice added to destination.');
} else {
$_SESSION['notification'] = array('type'=>'bad','msg'=>'Could not add a divert notice to the destination.');
}
redirect(ROOT_URL.'stores.php?search='.$_REQUEST['search'].$pg.$st.$fl);
}
I've tried a few variations, but am just going round in circles.
Ultimately I need to retried the date time string from ('#divert_until_<?php echo $v['id']; ?>').text()
Thanks!