SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP Form to Flat File Date Error...

    Hello all, I have a PHP question about posting to a Flat File. I am not getting the correct DATE() stamp... I get 1161230400 when I push Submit on my form for the TOMORROW date.

    Any clues? Here is my whole code file:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>FFDB</title>
    <style type="text/css">
    <!--
    .style1 {color: #FF0000}
    -->
    </style>
    </head>
    
    <body>
    <?php
    $now = time();
    //current date
    $date = date("l, d F Y - h:i a",time() - 10800);
    //tomorrow [QUOTE]- where problem is[/QUOTE]
    $tomorrow  = mktime(0, 0, 0, date("m", $now)  , date("d", $now)+1, date("Y", $now));
    
    //make sure all data is ready for post
    if(isset($_POST['Submit'])){
       $cpal1 = $_POST['cpal1'];   
       $cpal2 = $_POST['cpal2'];
       $cpal3 = $_POST['cpal3'];
       $cpal4 = $_POST['cpal4'];
       $cpal5 = $_POST['cpal5'];
       $csal1 = $_POST['csal1'];
       $csal2 = $_POST['csal2'];
       $csal3 = $_POST['csal3'];
       $csal4 = $_POST['csal4'];
       $csal5 = $_POST['csal5'];
       $ppal1 = $_POST['ppal1'];   
       $ppal2 = $_POST['ppal2'];
       $ppal3 = $_POST['ppal3'];
       $ppal4 = $_POST['ppal4'];
       $ppal5 = $_POST['ppal5'];
       $psal1 = $_POST['psal1'];
       $psal2 = $_POST['psal2'];
       $psal3 = $_POST['psal3'];
       $psal4 = $_POST['psal4'];
       $psal5 = $_POST['psal5'];
       
       $err = '';
       
       if(empty($csal1)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($csal2)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($csal3)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($csal4)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($csal5)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($cpal1)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($cpal2)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($cpal3)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($cpal4)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($cpal5)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($psal1)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($psal2)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($psal3)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($psal4)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($psal5)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($ppal1)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($ppal2)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($ppal3)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($ppal4)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if(empty($ppal5)){
          $err .= '<span class="style1">Please Enter ALL Date</span><br>';
       }
       if($err!=''){
          echo $err;
       }
       //if the form is all good, move on
       else{
          $filename = 'firedata.txt';
          $filetext = $cpal1 . '#' . $cpal2 . '#' . $cpal3 . '#' . $cpal4 . '#' . $cpal5 . '#' . $csal1 . '#' . $csal2 . '#' . $csal3 . '#' . $csal4 . '#' . $csal5 . '#' . $date . "\n" . $ppal1 . '#' . $ppal2 . '#' . $ppal3 . '#' . $ppal4 . '#' . $ppal5 . '#' . $psal1 . '#' . $psal2 . '#' . $psal3 . '#' . $psal4 . '#' . $psal5 . '#' . [B]$tomorrow[/B] . "\n";
          
          // Let's make sure the file exists and is writable first.
          if (is_writable($filename)) {
          
             // that's where $filetext will go when we fwrite() it.
             if (!$handle = fopen($filename, 'w')) {
                 echo "Cannot open file ($filename)";
                 exit;
             }
          
             // Write $filetext to our opened file.
             if (fwrite($handle, $filetext) === FALSE) {
                echo "Cannot write to file ($filename)";
                exit;
             }
             
             echo "Success, wrote ($filetext) to file ($filename)";
             
             fclose($handle);
          
          } else {
             echo "The file $filename is not writable";
          }
       }
    }
    ?>
    <form name="form1" method="post" action="index.php">
    	<p>
    	<h4>Actual Activity Levels</h4>
    	</p>
      <p>PAL - BOGARD:
        <input name="cpal1" type="text" id="cpal1" value="cpal1" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - CHESTER:
        <input name="cpal2" type="text" id="cpal2" value="cpal2" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - GORDON:
        <input name="cpal3" type="text" id="cpal3" value="cpal3" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - LADDER:
        <input name="cpal4" type="text" id="cpal4" value="cpal4" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - MANZANITA:
        <input name="cpal5" type="text" id="cpal5" value="cpal5" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - BOGARD:
        <input name="csal1" type="text" id="csal1" value="csal1" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - CHESTER:
        <input name="csal2" type="text" id="csal2" value="csal2" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - GORDON:
        <input name="csal3" type="text" id="csal3" value="csal3" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - LADDER:
        <input name="csal4" type="text" id="csal4" value="csal4" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - MANZANITA:
        <input name="csal5" type="text" id="csal5" value="csal5" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	<p>
    	<h4>Predicted Activity Levels</h4>
    	</p>
      <p>PAL - BOGARD:
        <input name="ppal1" type="text" id="ppal1" value="ppal1" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - CHESTER:
        <input name="ppal2" type="text" id="ppal2" value="ppal2" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - GORDON:
        <input name="ppal3" type="text" id="ppal3" value="ppal3" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - LADDER:
        <input name="ppal4" type="text" id="ppal4" value="ppal4" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	PAL - MANZANITA:
        <input name="ppal5" type="text" id="ppal5" value="ppal5" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - BOGARD:
        <input name="psal1" type="text" id="psal1" value="psal1" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - CHESTER:
        <input name="psal2" type="text" id="psal2" value="psal2" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - GORDON:
        <input name="psal3" type="text" id="psal3" value="psal3" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - LADDER:
        <input name="psal4" type="text" id="psal4" value="psal4" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	SAL - MANZANITA:
        <input name="psal5" type="text" id="psal5" value="psal5" size="6" style="text-transform: uppercase;" maxlength="6">
        <br>
    	
    </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form> 
    </body>
    </html>
    Thanks for any help!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mktime() returns an integer unix timestamp.

    if you want to convert this timestamp into a formatted date, feed the timestamp to the date() function.

  3. #3
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! Worked just right like this:

    PHP Code:
    $tomorrow date("l, d F Y"mktime(000date("m"$now)  , date("d"$now)+1date("Y"$now))); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •