Ok i'm looking to create something like...

Discussion in 'PHP' started by mattonline, May 8, 2007.

  1. #1
    Ok i'm looking to create something like...http://dropdates.co.uk/
    The calendar code is below but i need to add a feature in, i want to see what date it will be 92 & 99 days after the user inputs the dates into the system. You with me.....


    <form action="" method="post">
    <span class="row2"><select name="month" id="month">
                   <option selected="selected">Month</option>
                   <option>January</option>
                   <option>Febuary</option>
                   <option>March</option>
                   <option>April</option>
                   <option>May</option>
                   <option>June</option>
                   <option>July</option>
                   <option>August</option>
                   <option>September</option>
                   <option>October</option>
                   <option>November</option>
                   <option>December</option>
                 </select>
                 <select name="day" id="day">
                   <option selected="selected">Day</option>
                   <option>1</option>
                   <option>2</option>
                   <option>3</option>
                   <option>4</option>
                   <option>5</option>
                   <option>6</option>
                   <option>7</option>
                   <option>8</option>
                   <option>9</option>
                   <option>10</option>
                   <option>11</option>
                   <option>12</option>
                   <option>13</option>
                   <option>14</option>
                   <option>15</option>
                   <option>16</option>
                   <option>17</option>
                   <option>18</option>
                   <option>19</option>
                   <option>20</option>
                   <option>21</option>
                   <option>22</option>
                   <option>23</option>
                   <option>24</option>
                   <option>25</option>
                   <option>26</option>
                   <option>27</option>
                   <option>28</option>
                   <option>29</option>
                   <option>30</option>
                   <option>31</option>
                 </select>
                 <select name="year" id="year">
                   <option selected="selected">Year</option>
                   <option>03</option>
                   <option>04</option>
                   <option>05</option>
                   <option>06</option>
                   <option>07</option>
                   <option>08</option>
                 </select>
                 <input name="submit" type="submit" id="submit" value="submit">
    </span>
    </form>
    PHP:
     
    mattonline, May 8, 2007 IP
  2. xooMan

    xooMan Peon

    Messages:
    92
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In PHP try this:

    
    $t1 = strtotime('+92 day');
    $t2 = strtotime('+99 day');
    
    PHP:
    Now, $t1 and $t2 contain timestamps in the future. You can pass them to date() function, for example, to format as string.

    HTH
     
    xooMan, May 11, 2007 IP
  3. mattonline

    mattonline Active Member

    Messages:
    897
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    70
    #3
    $t1 = strtotime('+92 day');$t2 = strtotime('+99 day');
    PHP:
    where would i put that in the code, sorry i'm new to PHP and have really only mastered databases,
     
    mattonline, May 11, 2007 IP
  4. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You would calculate the future date after you have retrieved the input data from the form. Your sample is not PHP code. It is HTML output. Your PHP program is the one which will be called from the form's action="" attribute. The program would gather the date bits together to create a valid date value to which you can add your offset. You will also need to add value="" attributes to your options so that your program knows what was returned.

    The form might look like:

    
    <form action="myscript.php" method="post">
    <select name="month" id="month">
    <option selected="selected" value="00">Month</option>
    <option value ="January">January</option>
    <option value ="February">Febuary</option>
     . . . </select>
    <select name="day" id="day">
    <option selected="selected" value="0">Day</option>
    <option value="1">1</option>
    <option value="2">2</option>
    . . . 
    </select>
    <select name="year" id="year">
    <option selected="selected" value="00">Year</option>
    <option value="2003">03</option>
    . . . </select>
    <input name="submit" type="submit" id="submit" value="submit">
    </form>
    
    HTML:
    Some code in myscript.php might look like:

    
    if(!empty( $_POST['month'] )) { $theMonth = $_POST['month']; }
    if(!empty( $_POST['day'] )) { $theDay = $_POST['day']; }
    if(!empty( $_POST['year'] )) { $theYear = $_POST['year']; }
    
    $theDate = "$theDay $theMonth $theYear";
    $theTime = strtotime($theDate);
    $d1 = date("d M Y", $theTime + 60*60*24*92);
    $d1 = date("d M Y", $theTime + 60*60*24*99);
    
    echo "\n$d1\n$d2\n"; exit;
    
    PHP:
     
    clancey, May 11, 2007 IP
  5. mattonline

    mattonline Active Member

    Messages:
    897
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Thanks alot for that :) helped me out alot its up and working now

    http://0q6.com/form.php

    you made a small mistake here

    $d1 = date("d M Y", $theTime + 60*60*24*92);
    $d1 = date("d M Y", $theTime + 60*60*24*99);
    echo "\n$d1\n$d2\n"; exit;

    You put $d1 twice and it was just showing up the 92 days result, but i changed it now and it shows the both results.

    one last question, how do i put the result on a seperate line and put a peice of writing next to them like ' Your domain will drop' .............
     
    mattonline, May 11, 2007 IP
  6. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sorry about that small mistake. Cut and paste can be a friend and not . . .

    I put the echo statement in so your could see the concept works. If you are sending something back to the user you will want to mark it up as HTML. For instance:

    echo "<p>Your domain will drop $d2</p>";
    or
    echo "<p>Your domain will drop " . $d2 . "</p>";
     
    clancey, May 11, 2007 IP
  7. mattonline

    mattonline Active Member

    Messages:
    897
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    70
    #7
    Thanks will add that in asap :)
     
    mattonline, May 12, 2007 IP
  8. mattonline

    mattonline Active Member

    Messages:
    897
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    70
    #8
    mattonline, May 12, 2007 IP