[SOLVED] getdate and form data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vaavi8r
Forum Newbie
Posts: 2
Joined: Thu Nov 13, 2003 1:27 pm

[SOLVED] getdate and form data

Post by vaavi8r »

OK, I am trying to get the current date to show as a 'default' in the text box of my form, with the ability to change it if needed.

Here is my code:

Code: Select all

<HEAD>
<BODY background="sky01.jpg">
<TITLE>PIREP INPUT FORM</TITLE>
<center><h2>AUTOMATED PIREP REPORTING FORM</h2></center>
<b>Please complete all information in the formats described next to the input boxes. Your data will be automatically added to your flight log and your totals updated.<P>
<?
$today = getdate(); 
$month = $today['mon']; 
$day = $today['mday'];
$year=$today['year'];

?> 

<form method="post" action="script.php">
DATE: <input type="text" name="date" value="<?php echo $year/$month/$day;?>">
><B>FORMAT='YYYY-MM-DD'</b><br>
NAME: <input type="text" name="name"><br>
MACID: <input type="text" name="macid">USE YOUR FULL CALLSIGN "MACxxx"<br>
FLIGHT TIME: <input type="text" name="hours">Enter as a decimal, rounded to one decimal place. <br>If you are flying a charter flight, please double your hours before entering the total here.<br>
TYPE OF FLIGHT: <SELECT name="type">
<OPTION SELECTED>Macnet
<OPTION>Bushnet
<OPTION>Vatsim
<OPTION>Offline
<OPTION>Charter
<OPTION>Codeshare
<OPTION>Club Event
</select><BR>
DEPARTURE: <input type="text" name="departure"><b>USE ICAO CODE ONLY</b><br>
DESTINATION: <input type="text" name="destination"><b>USE ICAO CODE ONLY</b><br>
CHARTER #: <input type="text" name="charterno"><br>
CHARTER PAY: $<input type="text" name="charterdoll"><br>
COMMENT: <br><TEXTAREA name="comment" rows="10" cols="30"></TEXTAREA><br>

<input type="submit" name="submit" value="SUBMIT ">
</form> 
</html>
What I am getting in the form is the "<?php echo $year/$month/$day;?>"
showing inside the entry field. What am I doing wrong?

[Edit: Added php-tags for easier reading. --JAM]
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

DATE: <input type="text" name="date" value="<?php echo date ("Y/m/d");?>">
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

if you wanted to use your method then you need to correct your syntax

Code: Select all

<?php echo "$year/$month/$day" ; ?>
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

Sorry, should have finished reading your post.. Is the page you are working with have a .php extension? If not that is your problem
vaavi8r
Forum Newbie
Posts: 2
Joined: Thu Nov 13, 2003 1:27 pm

Post by vaavi8r »

YEP, that was the problem...changed the extention to .php and it works. Thanks
Post Reply