Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

click submit button, then echo something problem

Status
Not open for further replies.

sd0t1

IS-IT--Management
Mar 14, 2007
131
US
I'm trying to build a form that lets a user enter a day, time arrived, time left and time for lunch,then click insert to update a data base.
once it's inserted a new identical form should appear to collect the same data, but for the next day.
(Overall when the user is done they will have entered all there work hours for the week and I'll minus lunch times to see if they qualify for any overtime).

this is my code, I can't make the form show on the screen and on the "onclick" event submit and reshow the new identical form.
Please help.

<form id="form1" name="form1" method="post" action="ot_request.php">
<table width="805" height="51" border="0" cellpadding="0" cellspacing="0">

<tr>
<th width="182" height="21" align="left" valign="top" scope="row">Day</th>
<td width="182" align="left" valign="top"><strong>Time Arrived </strong></td>
<td width="182" align="left" valign="top"><strong>Time Departed</strong></td>
<td width="182" align="left" valign="top"><strong>Time Taken For Lunch</strong></td>
<td width="77" align="left" valign="top">&nbsp;</td>
<?php
if (isset($_POST['Submit'])) {
while ($x > 1){
$eday =

"<tr>
<th height='30' align='left' valign='top' scope='row'><p>
<input type='text' name='day' /></p>
</th>
<td align='left' valign='top'><p>
<input type='text' name='arrived' />
</p>
</td>
<td align='left' valign='top'><p>
<input type='text' name='left' /></p>
</td>
<td align='left' valign='top'><p>
<input type='text' name='lunch' />
</p>
</td>
<td align='left' valign='top'>&nbsp;</td>
</tr>";

echo $eday;}} ?>
</tr>
</table>
<p>
<label>
<input type="submit" name="Submit" value="New Entry" onclick"<?php $x++;?>"/>
</label>
</p>
</form>
 
why are you using javascript?

something as simple as this would work

Code:
<?php

if (isset($POST['submit'])){
 processFormResults();
}
function processFormResults(){
//do something with the form data
}
$entrydate = isset($_POST['entrydate']) ? date("Y-m-d", strtotime("+1 day", strtotime($_POST['entrydate']))) : date("Y-m-d");
?>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
Enter date (YYYY-mm-dd): 
<input type="text" name="entrydate" value="<?=$entrydate?>"/><br/>
<input type="submit" name="submit" value="Save" />
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top