Solved

PHP Code

Posted on 2014-07-22
4
372 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php mail headers 2 12
JavaScript Scope issue 4 20
php connect() failed error 25 16
two tables one button 11 16
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 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

20 Experts available now in Live!

Get 1:1 Help Now