b3nky Posted June 4, 2012 Share Posted June 4, 2012 Hello! first of sorry if similar thread exist. i'm little bit in hurry, i have exam on wednesday. this is beginner question. i'm working on some jqm site (ovulation calculation calendae). i have a form in which user enters in first field number (days of cycle) in second one enters the date from calendar. the date is in format y-m-d my problem is how to manage in php, so he can take days of cycle and add it to date chosen by user? this is my current progress...i know it looks simple to you...but this is my beginning. <form action="php.php" method="post"> <label for="slider-0">Cycle:</label> <input type="range" name="slider" id="slider-0" value="30" min="20" max="40" /> <label for="defcal">Beginning of last menstrual cycle?</label><input name="defcal" type="date" data-role="datebox" id="defcal" data-options='{"mode": "calbox"}'/> <input type="submit" value="Calculate" /> </form> <?php $ciklus= $_POST["slider"]; $zciklus= $_REQUEST["defcal"]; $zciklus= strtotime($zciklus); $ciklus= date('d'); $datum= date('d-M-y ', strtotime("+10 days")); echo "Cycle value is bla bla bla: ".$ciklus . "days.<br>"; ?> Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/263666-calculate-date/ Share on other sites More sharing options...
Barand Posted June 4, 2012 Share Posted June 4, 2012 try <?php $ciklus = $_POST["slider"]; $zciklus = $_POST["defcal"]; $zciklus = strtotime($zciklus); $datum = date('d-M-y', strtotime("+$ciklus days", $zciklus)); echo "Next date: $datum <br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/263666-calculate-date/#findComment-1351231 Share on other sites More sharing options...
b3nky Posted June 5, 2012 Author Share Posted June 5, 2012 as return result i get undefined... Quote Link to comment https://forums.phpfreaks.com/topic/263666-calculate-date/#findComment-1351487 Share on other sites More sharing options...
Barand Posted June 5, 2012 Share Posted June 5, 2012 add this code and post the output echo '<pre>' . print_r($_POST, 1) . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/263666-calculate-date/#findComment-1351488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.