Jump to content

insert datestamp into simple form?


kemper

Recommended Posts

My form is:

<style type="text/css">
<!--
.style1 {font-family: arial}
.style2 {color: #FF0000}
.style3 {color: #FFFFFF}
-->
</style>
<form enctype='multipart/form-data' action='processgamereport.php' method='post'>
<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000066" width="100%" cellpadding="5"><tr bgcolor="3C64A0"><td height="16" colspan="2" bordercolor="#FFFFFF"><font size="1" face="Verdana"><span class="style3">Please fill in all fields marked with a</span> <span class="style2">*</span></font></td></tr><tr>
  <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Team Name:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='TeamName' size=50>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Age and Division:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<select name='AgeDivision'><option value='Select One Below'>Select One Below<option value='Girls U-9/10 Blue'>Girls U-9/10 Blue<option value='Girls U-9/10 Red'>Girls U-9/10 Red<option value='U-7 Blue'>U-7 Blue<option value='U-8 Blue'>U-8 Blue<option value='U-8 Red'>U-8 Red<option value='U-9 Blue'>U-9 Blue<option value='U-9 Red'>U-9 Red<option value='U-10 Blue'>U-10 Blue<option value='U-10 Red'>U-10 Red<option value='U-10 Yellow'>U-10 Yellow<option value='U-11 A Blue'>U-11 A Blue<option value='U-11 A Red'>U-11 A Red<option value='U-11 B Yellow'>U-11 B Yellow<option value='U-11 B Green'>U-11 B Green<option value='U-11 C Purple'>U-11 C Purple<option value='U-11 C Orange'>U-11 C Orange<option value='U-11 C White'>U-11 C White<option value='U-12 A Blue'>U-12 A Blue<option value='U-12 B Yellow'>U-12 B Yellow<option value='U-12 B Green'>U-12 B Green<option value='U-12 C Purple'>U-12 C Purple<option value='U-12 C Orange'>U-12 C Orange<option value='U-13 A Blue'>U-13 A Blue<option value='U-13 A Red'>U-13 A Red<option value='U-13 B Yellow'>U-13 B Yellow<option value='U-13 B Green'>U-13 B Green<option value='U-13 C Purple'>U-13 C Purple<option value='U-14 A Blue'>U-14 A Blue<option value='U-14 A Red'>U-14 A Red<option value='U-14 B Yellow'>U-14 B Yellow<option value='U-14 C Purple'>U-14 C Purple</select>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Name of person completing this form:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Name' size=40>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Position:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<select name='Position'><option value='Select One Below'>Select One Below<option value='Coach'>Coach<option value='Manager'>Manager</select>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Telephone Number</span></font></p>
  <p style="margin-top: 0; margin-bottom: 0"><span class="style1">
  <font size="2">(###-###-####):</font></span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Telephone' size=40>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">email:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='email' size=50>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Game ID:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='GameID' size=8></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Game Date:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Date' size=30>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Game Time:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Time' size=30>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Home Team:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Home' size=50>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><span class="style1">
  <font size="2">Final Home Score:</font></span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='HomeScore' size=2>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Visiting Team:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Visitors' size=50>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Final Visitors Score:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='VisitorsScore' size=2>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Field:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Field' size=50>
<span class="style2">*</span></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Referees Name:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<input type=text name='Referee' size=50></td></tr><tr>
    <td width="220" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
  <p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">
  <span class="style1">Comments:</span></td>
<td width="960" height="30" bordercolor="#FFFFFF" bgcolor="eeeeee" valign="top">
<font face="Verdana">
<p style="margin-top: 0; margin-bottom: 0">
<textarea name='Comments' rows=6 cols=50></textarea></td></tr><tr bgcolor="#EEEEEE">
    <td colspan="2" height="25" valign="top">
    <p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2"><input type=submit value='Submit Form'>               <input type=reset value='Reset Form'></font></td></tr>
</table>
</form>

 

My process is:

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','team');
pt_register('POST','agedivision');
pt_register('POST','name');
pt_register('POST','position');
pt_register('POST','telephone');
pt_register('POST','email');
pt_register('POST','gameid');
pt_register('POST','date');
pt_register('POST','time');
pt_register('POST','home');
pt_register('POST','hscore');
pt_register('POST','visitors');
pt_register('POST','vscore');
pt_register('POST','field');
pt_register('POST','referee');
pt_register('POST','comments');
$comments=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $comments);if($team=="" || $agedivision=="" || $name=="" || $position=="" || $telephone=="" || $email=="" || $date=="" || $time=="" || $home=="" || $hscore=="" || $visitors=="" || $vscore=="" || $field=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="team: ".$team."
agedivision: ".$agedivision."
name: ".$name."
position: ".$position."
telephone: ".$telephone."
email: ".$email."
gameid: ".$gameid."
date: ".$date."
time: ".$time."
home: ".$home."
hscore: ".$hscore."
visitors: ".$visitors."
vscore: ".$vscore."
field: ".$field."
referee: ".$referee."
comments: ".$comments."
";
$message = stripslashes($message);
mail("me@mysite.org","Game Report Submission",$message,"From: $team");
$link = mysql_connect("host","username","password");
mysql_select_db("database",$link);
$query="insert into s2007gamereports (team,agedivision,name,position,telephone,email,gameid,date,time,home,hscore,visitors,vscore,field,referee,comments) values ('".$team."','".$agedivision."','".$name."','".$position."','".$telephone."','".$email."','".$gameid."','".$date."','".$time."','".$home."','".$hscore."','".$visitors."','".$vscore."','".$field."','".$referee."','".$comments."')";
mysql_query($query);

header("Refresh: 0;url=thankyou.php");
?><?php 
}
?>

 

How do I get datestamp for each result?  Which file needs editting?  Thanks!

Link to comment
Share on other sites

I added a datestamp field to my MySql table so that I know when the game report has been submitted.  I want it added to that I know when the form was submitted.  I do not want to manually input by the person giving the submission.  I want it automatic, like the auto_inclemented id

Link to comment
Share on other sites

you can assemble a timestamp from the following type of input:

 

02-06-2007  ( a format utilized by many pop-up javascript calenders -- or you can force input into that format with a mask. ) Place this code after your submit string, but before the INSERT string. If you have only one timestamp field, and the date is left blank, it will default to today. If you create a second timestamp field for this string, your default field will show you the date the record was added.

 

$daystring2 = $Date;

$month = substr($daystring2, 0, 2);

$day = substr($daystring2, 3, 2);

$year = substr($daystring2, 6, 4);

$fill = "000000";

$begindate  = $year.$month.$day.$fill;    // this will be your timestamp

 

 

 

Hope this helps,  :)

Link to comment
Share on other sites

A decision has to be made if the game scores are ALWAYS added the day of the game, or at a later date. This will impact the logic of being able to use today's date versus a date of two days ago, in which case you need user input. If you have a games schedule, maybe you could explore using a join and update the field automtaically.

 

Otherwise consider using a second date field, just for the day it was played. It does not have to be a timestamp, for example:

 

   <select name="month">
<option value="<?php echo date ("F", mktime()) ?>"><?php echo date ("F", mktime()) ?></option>
<option value="January">January </option>
<option value="February">February </option>
<option value="March">March </option>
<option value="April">April </option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November </option>
<option value="December">December </option>
</select>
									 <select name="day">
<option value="<?php echo date ("j", mktime()) ?>"><?php echo date ("j", mktime()) ?></option>
<?php
for ($x=1; $x<=31; $x++) {
   print "\t<option";
   print ($x == $year)?" SELECTED":"";
   print ">$x\n";
}
?>
</select> 
<select name="year">
<option value="<?php echo date ("Y", mktime()) ?>"><?php echo date ("Y", mktime()) ></option>
     <?php
        for ($x=2006; $x<=2010; $x++) {
        print "\t<option ";
print ($x == $year)?" SELECTED":"";
          print ">$x\n";
        }
          ?>
</select> 

 

Hope this clarifies options :)

Link to comment
Share on other sites

When I viewed it in code I saw sapce tags added... not sure why, but heres the code again... Make sure to set the year to your time frame.

 

  <select name="month">

<option value="<?php echo date ("F", mktime()) ?>"><?php echo date ("F", mktime()) ?></option>

<option value="January">January </option>

<option value="February">February </option>

<option value="March">March </option>

<option value="April">April </option>

<option value="May">May</option>

<option value="June">June</option>

<option value="July">July</option>

<option value="August">August</option>

<option value="September">September</option>

<option value="October">October</option>

<option value="November">November </option>

<option value="December">December </option>

</select>

<select name="day">

<option value="<?php echo date ("j", mktime()) ?>"><?php echo date ("j", mktime()) ?></option>

<?php

for ($x=1; $x<=31; $x++) {

    print "\t<option";

    print ($x == $year)?" SELECTED":"";

    print ">$x\n";

}

?>

</select>

<select name="year">

<option value="<?php echo date ("Y", mktime()) ?>"><?php echo date ("Y", mktime()) ></option>

      <?php

        for ($x=2005; $x<=2006; $x++) {

        print "\t<option ";

print ($x == $year)?" SELECTED":"";

          print ">$x\n";

        }

          ?>

</select>

Link to comment
Share on other sites

For clarification, I am using the logic of loggin datestamp as most (if not all CMSs use).  When I add news items within my site CMS system,  I do not add the news_datestamp.  I have been dissecting my news.php and articles.php forms to see how it is coded for datestamp and am having difficulties following.

 

For the soccer league that I run, online game reports are to be submitted within 48 hours of completion of each game and are not automatically updated online.  They are collected in an independent table for review.  This is due to teams that do not collect accurate scores.  Both teams report different scores constantly, so we have not developped policy to have winning team report the scores and automatically update the "TRUE" results table.

 

Thanks!

Link to comment
Share on other sites

I tried adding richardw's recommendations, but I do not want the user who is submitting info to add the date.  That gave edittible fill in fields.  Think of an email...  Does the person who is sending it add the sent time?  No, not unless you are those spammers who are forging everything now.

 

I have my form code in the first post, it does not contain datestamp fields.  I want that automatically generated everytime submit button is pressed.

 

Suggestions are greatly appreciated.

Link to comment
Share on other sites

Hello! Just add a date field to the table structure and make sure its a timestamp. Take the date field out of your form, and if you have only one timestamp field, it will automatically have the date the form is submitted. Make sure this is not the date field in your form, or it will provide an empty timestamp the way your INSERT statement is currently configured.

 

Let me know if I can clarify this further. You will always be able to retrieve the timestamp and format it as you wish in your reports.

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.