Link to home
Start Free TrialLog in
Avatar of wantabe2
wantabe2Flag for United States of America

asked on

PHP Code

The code below works great but I do have one question about it. Is there any way for me to edit the code

<p><b>Date Completed:</b> <br> <input type="date" name="datepicker_comp" id="datepicker_comp" size="15" value = "YYYY-MM-DD"/></p>

So instead of showing the value of YYYY-MM-DD, it will echo or show today's date 2014-07-22?

The entire code snip it is below & the line of code in question is on line 11.

<?php

echo '<form action="complete.php" method="post">

<fieldset><legend><h2>If you have completed this assignment, click "Complete Task" below.</h2></legend>

<b>Place No:</b> <br><input type="text" name="place" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>Name:</b> <br><input type="text" name="name" size="35" maxlength="30" value="'.$row[1].'" /><br />
<b>Task:</b><br><input type="text" name="task" size="45" maxlength="35" value="'.$row[2].'" onchange="checkme()"/> <br>
<b>Date Due:</b><br><input type="text" name="datepicker" size="15" maxlength="30" value="'.$row[3].'" onchange="checkme()"/> <br>
<p><b>Date Completed:</b> <br> <input type="date" name="datepicker_comp" id="datepicker_comp" size="15" value = "YYYY-MM-DD"/></p>
<b>Employee:</b><br><input type="text" name="your_name" size="35" maxlength="30" value="'.$row[4].'" onchange="checkme()"/> <br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Complete Task" /></div> 

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else { // Not a valid user ID.
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}

mysql_close(); // Close the database connection.

?>

Open in new window

Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

Sure use this for the value
date('Y-m-d');

Open in new window

just replace:
value = "YYYY-MM-DD"

by:
value = "<?php echo date(""Y-m-d"); ?>"
Avatar of wantabe2

ASKER

If I use:

<p><b>Date Completed:</b> <br> <input type="date" name="datepicker_comp" id="datepicker_comp" size="35" value = "<?php echo date(""Y-m-d"); ?>" </p>

Open in new window


I get the attached showing on the form...& it does not work
Capture.JPG
ASKER CERTIFIED SOLUTION
Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial