Solved

PHP Code

Posted on 2014-07-22
4
376 Views
Last Modified: 2014-07-22
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

0
Comment
Question by:wantabe2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:N R
ID: 40212760
Sure use this for the value
date('Y-m-d');

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40212763
just replace:
value = "YYYY-MM-DD"

by:
value = "<?php echo date(""Y-m-d"); ?>"
0
 
LVL 15

Author Comment

by:wantabe2
ID: 40212784
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
0
 
LVL 11

Accepted Solution

by:
N R earned 500 total points
ID: 40212787
Looks like you're already echoing out so use:

value = "'.date('Y-m-d').'"

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now