Skip to content

Instantly share code, notes, and snippets.

@hiranipradeep
Last active January 27, 2017 17:36
Show Gist options
  • Save hiranipradeep/813b67aa6412b84e162b8e48be819622 to your computer and use it in GitHub Desktop.
Save hiranipradeep/813b67aa6412b84e162b8e48be819622 to your computer and use it in GitHub Desktop.
C:\wamp\bin\php\php7.0.4\php.exe C:\wamp\www\reminder\cron.php
<?php
echo "cron.php";
?>
-- phpMyAdmin SQL Dump
-- version 4.5.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 27, 2017 at 05:34 PM
-- Server version: 5.7.11
-- PHP Version: 7.0.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `reminder`
--
-- --------------------------------------------------------
--
-- Table structure for table `task`
--
CREATE TABLE `task` (
`task_id` int(5) NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`reccuring` char(1) NOT NULL,
`notes` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `task`
--
INSERT INTO `task` (`task_id`, `start_date`, `end_date`, `reccuring`, `notes`) VALUES
(1, '2017-01-26', '2017-01-27', 'y', 'notes'),
(2, '2017-01-26', '2017-01-28', 'q', 'notes'),
(3, '2017-01-26', '2017-01-29', 'y', 'notes'),
(4, '2017-01-26', '2017-01-30', 'm', 'notes'),
(5, '2017-01-26', '2017-01-31', 'y', 'notes'),
(6, '2017-01-26', '2017-02-01', 'q', 'notes'),
(7, '2017-01-26', '2017-02-02', 'y', 'notes'),
(8, '2017-01-26', '2017-02-03', 'm', 'notes'),
(9, '2017-01-26', '2017-02-04', 'y', 'notes');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `task`
--
ALTER TABLE `task`
ADD PRIMARY KEY (`task_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `task`
--
ALTER TABLE `task`
MODIFY `task_id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!--<link rel="stylesheet" href="/resources/demos/style.css">-->
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<form id="mainForm1" action="process.php" method="post">
<table>
<tr>
<td>Start Date: </td><td><input type="text" name="startdp" id="startdp"></td>
</tr>
<tr>
<td>End Date: </td><td><input type="text" name="enddp" id="enddp"></td>
</tr>
<tr>
<td>Task Name: </td><td><input type="text" name="taskname"></td>
</tr>
<tr>
<td colspan="2">
<fieldset>
<legend>Reccuring: </legend>
<input type="radio" name="reacuring" value="y"><label for="reacuring-1">Yearly</label><br>
<input type="radio" name="reacuring" value="q"><label for="reacuring-2">Quaterly</label><br>
<input type="radio" name="reacuring" value="m"><label for="reacuring-3">Monthly</label>
</fieldset>
</td>
</tr>
<tr><td colspan="2">
<table id="mainForm2">
<tr><td>30 Days Message:</td><td><input type="text" name="30msg" class="rectab"></td></tr>
<tr><td>15 Days Message:</td><td><input type="text" name="15msg" class="rectab"></td></tr>
<tr><td>Week Message:</td><td><input type="text" name="7msg" class="rectab"></td></tr>
<tr><td>Daily Message:</td><td><input type="text" name="1msg" class="rectab"></td></tr>
</table>
</tr></td>
<tr>
<td colspan ="2">
<button id="btnreccuring" type="button">Reccuring</button>
<button id="btnsave" type="button">Save</button>
<button id="btnclear" type="button">Clear</button>
</td>
</tr>
</table>
</form>
<script>
$(document).ready(function() {
$("#startdp, #enddp").datepicker();
$("#mainForm2").hide();
// set reacuring data
$("#btnreccuring").click(function(){
$("#mainForm2").show();
});
// clear form fileds
$("#btnclear").click(function(){
$(this).closest('form').find("input[type=text], textarea").val("");
});
// clear form fileds
$("#btnrclear").click(function(){
$(".rectab").val("");
});
// save form data
$("#btnsave").click(function(e){
jQuery("#mainForm2").serialize();
$.ajax({
type: "POST",
url: "process.php",
data: jQuery("#mainForm1").serialize(),
cache: false,
success: function(data){
alert(data);
//var book = $.parseJSON(data)
//alert(book);
// alert(data); if json obj. alert(JSON.stringify(data));
}
});
});
$("#mainForm11").click(function(e){
//$("#mainForm1").submit(function(e){
console.log('come');
var formObj = $(this);
var formURL = formObj.attr("action");
var formData = new FormData(this);
console.log(formData);
$.ajax({
url: 'process.php',
type: 'POST',
data: formData,
//success: function(data, textStatus, jqXHR){
// console.log(data);
//},
success: function(result){
alert(result);
},
error: function(jqXHR, textStatus, errorThrown) {}
});
//e.preventDefault(); //Prevent Default action.
//e.unbind();
});
//$("#mainForm1").submit(); //Submit the form
});
</script>
</body>
</html>
<?php
//echo json_encode($_POST);
//exit;
if(!empty($_POST['startdp'])){
$mysqli = new mysqli("localhost", "root", "", "reminder");
//check connection
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$query = "SELECT * FROM task";
$result = $mysqli->query($query);
while($row = $result->fetch_array()){
//echo "<br>".$row['end_date'];
$rows[] = $row['end_date'];
}
//free result set
$result->free();
//close connection
$mysqli->close();
//print_r($rows);
//return $rows;
echo json_encode($rows);
exit;
}else{
echo "nothing...";
exit;
}
?>
//schtasks /create /sc minute /mo 1 /tn "PHP Cron Job" /tr C:\wamp\www\reminder\cron.bat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment