PHP Variables Not Working

Discussion in 'PHP' started by drewtoby, Jul 9, 2011.

  1. #1
    Hello, I am trying to make a countdown php form. Everything seems to work okay, except I cannot get the php variables to equal the html name tags. My code is below. Please let me know what I messed up, as this is my first php creation :eek:.

    
    <html>
    <title>Make your own countdown php script!</title>
    
    
    
    <form>
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    
    Make your own countdown php script, which you can post to your site! </br> Want to add this feature to your site? Visit elvenprog.com to do so.
    </br></br>
    Event: <input type="text" size="10" maxlength="100" value="Name Your Event To Count Down To" name="event" />
    </br>
    </br>
    Day: <input type="text" size="10" maxlength="100" value="Enter Day Event Will Occur" name="day" />
    </br>
    </br>
    Month: <input type="text" size="10" maxlength="100" value="Enter Month Event Will Occur" name="month" />
    </br>
    </br>
    Year: <input type="text" size="10" maxlength="100" value="Enter Year Event Will Occur" name="year" />
    </br>
    </br>
    Hours: <input type="text" size="10" maxlength="100" value="Hours Until Event" name="hours" />
    </br>
    </br>
    Minutes: <input type="text" size="10" maxlength="100" value="Minutes Until Event" name="min" />
    </br>
    </br>
    Seconds: <input type="text" size="10" maxlength="100" value="Seconds Until Event" name="sec" />
    </br>
    </br>
    <input type="submit" name="sub"/>
    
    </form>
    
    
    </html>
    
    <?
    
    $_event=$_POST['event'];
    
    $_hours=$_POST['hours'];
    
    $_year=$_POST['year'];
    
    $_seconds=$_POST['sec'];
    
    $_minutes=$_POST['min'];
    
    $_month=$_POST['month'];
    
    $_day=$_POST['day'];
    
    $target = mktime($_hours, $_minutes, $_seconds, $_month, $_day, $_year) ;
    
    $today = time () ;
    
    $difference =($target-$today) ;
    
    $days =(int) ($difference/3600) ;
    
    
    
    if ($_year>0)
    {
    echo '$event will begin in $days hours.';
    }
    ?>
    
    Code (markup):

     
    drewtoby, Jul 9, 2011 IP
  2. SiJz

    SiJz Peon

    Messages:
    51
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    No problem...

    You need to lose the
    <form>
    Code (markup):
    at the top as it's replicated and confused things as it has no method nor action

    Also the output needs to change a little to:
    echo $event." will begin in ".$days." hours.";
    Code (markup):
    Hope that helps?

    Si
     
    SiJz, Jul 9, 2011 IP
  3. yusuyi

    yusuyi Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    And move </html> to the end of your script will be better
     
    yusuyi, Jul 9, 2011 IP
  4. drewtoby

    drewtoby Well-Known Member

    Messages:
    763
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Thanks! Code is working now!!!!!!!!!!!!
     
    drewtoby, Jul 9, 2011 IP
  5. yusuyi

    yusuyi Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you are welcome :)
     
    yusuyi, Jul 9, 2011 IP