Date (date and time) with MySQL, register here!

Hello

Summary:

I have a page (form) to capture traffic. It works, it allows the user to enter details of attendance. Click, he writes to the database - table. The date is not entered on the form. I want to date this stamp by inserting a date (date and time - declared field). I'll give you the source code. Please pin point what code I'd be inserting and assuming that everything in this code.

Question:

Insert the date and time in the database table-

Code:

<? php require_once('Connections/dbAttendance.php');? >

<? PHP

If (! function_exists ("GetSQLValueString")) {}

function GetSQLValueString ($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

If (via PHP_VERSION < 6) {}

$theValue = get_magic_quotes_gpc()? stripslashes ($TheValue): $theValue;

}

$theValue = function_exists ("mysql_real_escape_string")? mysql_real_escape_string ($TheValue): mysql_escape_string ($theValue);

Switch ($theType) {}

case 'text ':

$theValue = ($theValue! = "")? « " ». $theValue. "" "": "NULL";

break;

case "long":

case "int":

$theValue = ($theValue! = "")? intval ($TheValue): 'NULL ';

break;

case "double":

$theValue = ($theValue! = "")? doubleVal ($TheValue): 'NULL ';

break;

case "date":

$theValue = ($theValue! = "")? « " ». $theValue. "" "": "NULL";

break;

case "set":

$theValue = ($theValue! = "")? $theDefinedValue: $theNotDefinedValue;

break;

}

Return $theValue;

}

}

$editFormAction = $_SERVER ['PHP_SELF'];

If (isset {}

$editFormAction. = « ? ». htmlentities($_SERVER['QUERY_STRING']);

}

If ((isset($_POST["MM_insert"])) & & ($_POST ["MM_insert"] == 'form')) {}

$insertSQL = sprintf ("INSERT INTO attendlist (IDWindows, title, first name, name, mobile extension, jobrole, courses, GIC, mgrname, room) VALUES (%s, %s %s, %s, %s, %s, %s, %s, %s, %s, %s)", ")

GetSQLValueString ($_POST ["'textfield"], "text").

GetSQLValueString ($_POST ['select'], "text").

GetSQLValueString ($_POST ['textfield2 "],"text").

GetSQLValueString ($_POST ['textfield3'], "text").

GetSQLValueString ($_POST ['textfield4'], "text").

GetSQLValueString ($_POST ['textfield5'], "text").

GetSQLValueString ($_POST ['choisies5'], "text").

GetSQLValueString ($_POST ["select2"], "text").

GetSQLValueString ($_POST ['select4'], "text").

GetSQLValueString ($_POST ['textfield7'], "text").

GetSQLValueString ($_POST ['select3'], "text"));

@mysql_select_db ($database_dbAttendance, $dbAttendance);

$Result1 = mysql_query ($insertSQL, $dbAttendance) or die (mysql_error ());

$insertGoTo = "Thankyou.php";

If (isset {}

$insertGoTo. = (strpos ($insertGoTo, '?'))? « & » : « ? » ;

$insertGoTo. = $_SERVER ['QUERY_STRING'];

}

header (sprintf ("location: %s", $insertGoTo));

}

@mysql_select_db ($database_dbAttendance, $dbAttendance);

$query_rsAttendance = "SELECT * from attendlist";

$rsAttendance = mysql_query ($query_rsAttendance, $dbAttendance) or die (mysql_error ());

$row_rsAttendance = mysql_fetch_assoc ($rsAttendance);

$totalRows_rsAttendance = mysql_num_rows ($rsAttendance);

? >

< ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > ""

" < html xmlns =" http://www.w3.org/1999/xhtml ">

< head >

< meta http-equiv = "Content-Type" content = text/html"; charset = utf-8 "/ >"

< title > delegate registry < /title >

< link href = "Registerpage.css" rel = "stylesheet" type = "text/css" / > "

< link href = "SpryAssets/SpryValidationTextField.css" rel = "stylesheet" type = "text/css" / > "

< link href = "SpryAssets/SpryValidationSelect.css" rel = "stylesheet" type = "text/css" / > "

< script src = "SpryAssets/SpryValidationTextField.js" type = "text/javascript" > < / script > "

< script src = "SpryAssets/SpryValidationSelect.js" type = "text/javascript" > < / script > "

< / head >

<? PHP

$date = date ("format", $timestamp);

? >

< body >

< div class = "container" >

< div class = "header" > < img src = "Identify Imperial2.jpg" width = "960" height = "150" alt = "" / > <! - end .header - > < / div > "

< div class = "content" >

Registry < H3 >: <? PHP echo "Date -".date("d/m/y - H:ia"). > < / h3 >

< do action = "<?" PHP echo $editFormAction;? ">" method = "post" name = "form" >

< table width = "780" border = "0" >

< b >

< td > < div align = "right" > user ID * < / div > < table >

< td > < span id = "sprytextfield1" >

< input name = "textfield" type = "text" id = "textfield" tabindex = "1" size = "18" maxlength = "10" / >

< span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > title * < / div > < table >

< td > < span id = "spryselect1" >

< select name = "select" id = "select" tabindex = "2" >

< option value = '0' > select < / option >

< option value = "1" > Ms < / option >

< option value = "2" > Ms < / option >

< option value = "3" > Mdm < / option >

< option value = "4" > Dr. < / option >

< option value = "5" > Mr < / option >

< option value = "6" > Professor < / option >

< / select >

< span class = "selectRequiredMsg" > please select an item. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > name * < / div > < table >

< td > < span id = "sprytextfield2" >

< input name = "textfield2" type = "text" id = "textfield2" tabindex = "3" size = "30" maxlength = "30" / >

< span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > family name * < / div > < table >

< td > < span id = "sprytextfield3" >

< input name = "textfield3" type = "text" id = "textfield3" tabindex = "4" size = "30" maxlength = "30" / >

< span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > Contact / beep * < / div > < table >

< td > < span id = "sprytextfield4" >

< input name = "textfield4" type = "text" id = "textfield4" tabindex = "5" size = "30" maxlength = "30" / >

< span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > Mobile no: (optional) < / div > < table >

< td > < input name = "textfield5" type = "text" id = "textfield5" tabindex = "6" size = "20" maxlength = "20" / > < table >

< td > < table >

< /tr >

< b >

< td > < table >

< td > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > function * < / div > < table >

< td > < span id = "spryselect5" >

< select name = "choisies5" id = "choisies5" tabindex = "7" >

< option value = '0' > select < / option >

< option value = "1" > doctor < / option >

< option value = "2" > nurse IP < / option >

< option value = "3" > nurse OP < / option >

< option value = "4" > midwife < / option >

< option value = "5" > booking clerk < / option >

< option value = "6" > medical Secretary < / option >

< option value = "7" > OP receptionist < / option >

< option value = "9" > CNS/NP < / option >

< option value = "10" > test < / option >

< / select >

< span class = "selectRequiredMsg" > please select an item. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > manager name * < / div > < table >

< td > < span id = "sprytextfield5" >

< input name = "textfield7" type = "text" id = "textfield7" tabindex = "8" size = "30" maxlength = "30" / >

< span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < table >

< td > < table >

< td > < table >

< /tr >

< b >

< td > < table >

< td > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > course * < / div > < table >

< td > < span id = "spryselect2" >

< select name = "select2" id = "select2" tabindex = "9" >

< option value = '0' > select < / option >

< option value = "1" > demo < / option >

< option value = "2" > doctors < / option >

< option value = "9" > CNS/NP < / option >

< option value = "3" > nurse IP < / option >

< option value = "4" > nurse OP < / option >

< option value = "5" > midwife < / option >

< option value = "6" > booking clerk < / option >

< option value = "7" > medical Secretary < / option >

< option value = "8" > OP receptionist < / option >

< / select >

< span class = "selectRequiredMsg" > please select an item. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > location * < / div > < table >

< td > < span id = "spryselect3" >

< select name = "select3" id = "select3" tabindex = "10" >

< option value = '0' > select < / option >

< option value = "1" > CHX 12 floor Rm 1 < / option >

< option value = "2" > CHX 12 Floor Rm 2 < / option >

< option value = "3" > CHX 10 West < / option >

< option value = "4" > HH N207 < / option >

< option value = "5" > HH W12 Conference < / option >

< option value = "6" > Rm SMH one < / option >

< option value = "7" > Rm SMH b < / option >

< option value = "8" > SMH Ming wing Rm 5 < / option >

< option value = "9" > SMH Ming wing Rm 3 < / option >

< / select >

< span class = "selectRequiredMsg" > please select an item. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "right" > GIC * < / div > < table >

< td > < span id = "spryselect4" >

< select name = "select4" id = "select4" tabindex = "11" >

< option value = '0' > select < / option >

< option value = "1" > GIC 1 - medicine < / option >

< option value = "2" > GIC 2 - surgery and Cancer < / option >

< option value = "3" > GIC 3 - specialized Services < / option >

< option value = "4" > GIC 4 - Services circulatory and renal medicine < / option >

< option value = "5" > GIC 5 - women and children < / option >

< option value = "6" > GIC 6 - clinic and investigation Sciences < / option >

< option value = "7" > GIC 7 - private Patients < / option >

< option value = "8" > other < / option >

< / select >

< span class = "selectRequiredMsg" > please select an item. </span > < / span > < table >

< td > < table >

< /tr >

< b >

< td > < table >

< td > < input name = "button" type = "submit" id = "button" value = "Submit" / > < table >

< td > < table >

< /tr >

< b >

< td > < div align = "center" > * mandatory fields < / div > < table >

< td > < table >

< td > < table >

< /tr >

< /table >

< input type = "hidden" name = "MM_insert" value = "form" / >

< / make >

<! - end content - > < / div >

< div class = "footer" >

< p align = "center" >

" < a href =" http://validator.w3.org/check?URI=referer "> < img ".

      src=" http://www.w3.org/icons/valid-Xhtml10 "alt ="Valid XHTML 1.0"Transitional height ="31"width ="88"/ > < / a > "

< p align = "center" > Cerner@Imperial ICT training team < /p >

< /p >

<! - end .footer - > < / div >

<! - end .container - > < / div >

< script type = "text/javascript" >

var sprytextfield1 = new Spry.Widget.ValidationTextField ("sprytextfield1", "none", {validateOn: ["blur", "change"]});

var spryselect1 = new Spry.Widget.ValidationSelect ("spryselect1", {validateOn: ["change", "blur"]});

var sprytextfield2 = new Spry.Widget.ValidationTextField ("sprytextfield2", "none", {validateOn: ["blur", "change"]});

var sprytextfield3 = new Spry.Widget.ValidationTextField ("sprytextfield3", "none", {validateOn: ["blur", "change"]});

var sprytextfield5 = new Spry.Widget.ValidationTextField ("sprytextfield5", "none", {validateOn: ["blur", "change"]});

var spryselect2 = new Spry.Widget.ValidationSelect ("spryselect2", {validateOn: ["change", "blur"]});

var spryselect3 = new Spry.Widget.ValidationSelect ("spryselect3", {validateOn: ["change", "blur"]});

var spryselect4 = new Spry.Widget.ValidationSelect ("spryselect4", {validateOn: ["change", "blur"]});

var sprytextfield4 = new Spry.Widget.ValidationTextField ("sprytextfield4", "none", {validateOn: ["blur", "change"]});

var spryselect5 = new Spry.Widget.ValidationSelect ("spryselect5", {validateOn: ["blur", "change"]});

< /script >

< / body >

< / html >

<? PHP

mysql_free_result ($rsAttendance);

? >

There are several ways. One is to get the date of the php time() function and use it in your insert statement. Another is to use the MySQL CURDATE () function. But probably the easiest and best are simply set the default value for the column of date / time than the current date/time and exclude it from the insert statement. No required code changes.

http://dev.MySQL.com/doc/refman/5.0/en/timestamp-initialization.html

Tags: Dreamweaver

Similar Questions

  • Need to insert the Date and time with AM or PM

    StartDate form has ' 25/07/2006' and Starttime "13:07.
    I need to add this field in the database to display the Date and time with the AM or PM. But the result I get is false.
    <! - concatenate fields - >
    "< cfset Startdate = #Startdate # &" "& #starttime # >.

    < cfset startdate = #DateFormat (CreateODBCDateTime (Startdate), ' mm/dd/yyyy hh: mm: tt ') # >
    Here is my production. This is not the AM or PM conversion part of the chain.

    25/07/2006 01:07 am

    My database is SQL 2000

    You use any of dateformat. The createodbcdatetime sends the correct your DB value if you do it right.

  • Formatting of dates and times of MySQL

    I have a few questions that I hope you guys can help out me with...

    I have a MySQL DB that includes the columns 'date' and 'start_time', 'end_time '.  Date is stored as 'date' and start_time and end_time are stored as 'time '.

    When formatting a date in PHP, I found this page very useful: http://php.net/manual/en/function.date.php

    Does anyone know of a similar page showing the attributes that are available with the MySQL DATE_FORMAT.

    Also, I currently have the query written like this:

    SELECT id, title, description, DATE_FORMAT ('date', '% m/%d') AS formatted_date, start_time, end_time, location

    Events


    Does anyone know how I can format the columns of TIME similar to how I did the DATE columns?  I once stored as '08:00:00 ' and "21:30:00" and I want displayed them as '08:00 ' and «21:00»


    Any help? Thank you!

    The full list of formatting specifiers is in MySQL documentation at http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format.

    Use DATE_FORMAT()) for your time columns.

    DATE_FORMAT(theTime, '%l:%i%p') AS formatted_time
    

    I think MySQL is using AM and PM. If you want to lower case, just pass the result of the database to strtolower():

    
    
  • Issue date and time with the javascript scripts

    Hi all

    I need to maintain a bit of history on my pdf form, so I need to get the date and time when the user submits the form.  Currently, I am able to do this in FormCalc.

    var todayDate = Date()
    var todayTime = Time()
    var today = concat (Num2Date (todayDate, "MMMM DD, YYYY"), "", Num2Time (todayTime, "h: mm A") "");

    today will contain: April 28, 2009 14:23

    I want exactly the features in javascript.  I'm not able to get the same result.

    Please give me some code for the same in javascript snippet

    Deepak.

    Hi Deepak,

    This example should show you how you can recover each "piece" of the date in JavaScript and piece and then that their back together according to your needs.

    You will find several examples of scripts on the date formatting here: http://javascript.internet.com/time-date/

  • retriving records with date and time stamps

    I need to get all records that have been updated between 08:36:06 and 08:36:09 12/15/2009

    I use this application it gives me the numbers on the right (I think) because this condition GURMAIL_CPLN_CODE = 'UGAP', I want something more
    using the stamp date and time with dates
    12/15/2009 08:36:06 AM
    12/15/2009 08:36:07 AM
    12/15/2009 08:36:08 AM
    12/15/2009 08:36:09 AM
    select * from GURMAIL
    where 
    PERMAIL_CPLN_CODE = 'UGAP'
    AND TO_CHAR(PERMAIL_ACTIVITY_DATE,'MM/DD/YYYYHH24:MI:SS AM') >= '12/15/2009 08:36%'
    Thank you

    face-> Office (while exclaiming in despair "¿Dang, now how could I miss that?")

    Yes, Max, you're right, thanks for being there!
    When I never learn never to post a reply, unless I ran the code me first? ;)
    In any case: bed here now, ciao!

  • How do I set the date and time for those?

    Windows Vista; all the time that the I shoot my computer automatically go back to the year 2001; so whenever the I put on the computer I need to set up the date and time;  With the help of Windows, after the< is="" an="" error="">, but did not mention the number or how to fix it, please help

    Hello

    If after having set the time/Date and stop and restart your machine the time means the 2001 2007 2009 year ETC, you have a CMOS battery has failed in the motherboard.

    They cost about $5 and are easy to replace.

    How to replace a CMOS battery.

    http://www.computerhope.com/issues/ch000239.htm

    See you soon.

  • set the date and time on the content of oracle webCenter

    Hello

    Please tell me how to set the date and time with the location on the interface tab utility properties of the system.
    also tell me how to find the location on the interface tab content properties webCenter system utility

    Regards\
    Mayur mitkari

    Hello

    You need start the System/ucm/cs/bin properties applet. Virtue of the present, you see tab location option.

    Thank you
    Srinath

  • A few days, I bought a mac mini which I transferred the data and programs with time machine: programs have been updated except for iMovie, and now it seems that I have to pay for the update: possible? What I am doing wrong?

    A few days ago, I bought a mac mini and I transferred all my data and programs with time machine: all programs have been updated but iMovie (7.1.4)... However, it seems that, to update to the latest version, I have to pay to download on Appstore: is it possible? what I am doing wrong?

    If it were a new mac mini, you need already installed 10.1 iMovie.  Otherwise, but you already have iMovie 9 registered version to your Apple ID, you can upgrade to version 10 for free, but if (as it appears) is an earlier version then you have to buy version 10.

    Geoff.

  • Facing problem with date and time.

    * - Original title - BIOS

    Mr President.

    I have Compaq CQ2100IL Desktop pc for awhile I was faced with the problem of the date and time, so I posted this question to Microsoft, so they gave me a solution change my CMOS battery, so I did it, but despite this I get this error again then I tried and got answer to update my BIOS , I tried to find a version update on the HP site but did not find, so please help me in this matter.

    Hi Vikas,

    You can contact HP here: http://h10025.www1.hp.com/ewfrf/wc/contacthp?cc=us&dlc=en&lc=en&os=4062&product=3890751&sw_lang=

    Warning in the BIOS: BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

    Let us know if you need assistance with any windows problem. We will be happy to help you.

  • Working with date and time of the request for help from acrobat JavaScript...

    This coming from

    Working with date and time in Acrobat JavaScript (part 1 of 3)

    The following code adds five days to the current date, and then prints the new date in the console window.

    Get the date and time

    var rightNow = new Date();

    Get the value of millisecond

    Article date

    var msRightNow = rightNow.getTime ();

    Calculate in milliseconds, of 5 days

    5 days x 24 hours/day x 60 min / h x 60 s / min x 1000 ms/s

    Challenge of var = 5 * 24 * 60 * 60 * 1000;

    Do the calculation of var CFAbsoluteTime = msRightNow + challenge;

    Create a new Date from the calculated value

    var theNewDate = new Date (finalTime);

    In the actual work on a form code, you'll want to place the

    the object of a field value. But since this is test code, we will

    Print the result to the Console window (great for debugging)

    Console.println ("5 days from now is:" + theNewDate.toString ());

    The foregoing is the exact code (cut and paste)

    The error I get here is;

    ReferenceError: theNewDate is not defined

    1:Console:exec

    undefined

    To get the "undefined" question a lot... it seems to me, learn to distinguish the undefined 'of type' undefined 'variable' and undefined 'value '.

    in this case 'theNewDate' seems to be defined as a variable equal to the current date plus 5 days... BUT I am now "educated" enough to 'see' Why am I getting the error...


    Any thoughts... Any who...

    You need to highlight all the text that you want to run.

    You have not set the rightNow variable before you can apply a method to the variable.

    You can just add a new variable as msRightNow name. Why not use rightNow.

    Executes the code that you provided with a new departure of Acrobat, I get the following error messages:

    rightNow.getTime is not a function

    1:Console:exec

    TypeError: rightNow.getTime is not a function

    1:Console:exec

    undefined

    What you are showing probably works because your previous attempts have left behind them a variable "rightNow" and as long as you do not have the object of time date change too much, you will not notice the error.

    Cleaning of your code:

    get the number of milliseconds of the date object.

    rightNow var = (new Date()) .getTime ();

    define 5 days in milliseconds;
    Challenge of var = 5 * 24 * 60 * 60 * 1000;

    Add 5 days to the value of this moment and assign the result to the last time;
    var CFAbsoluteTime = rightNow + challenge;

    convert finalTime value in a date object.
    var theNewDate = new Date (finalTime);

    display the result;
    Console.println ("5 days from now is:" + theNewDate.toString ());

    Have you tried the code that I provided, it is another way to add days to the date object.

  • How can I save my browser history, with dates and times included?

    I need save my history of the browser with the date and hours included. I tried to do the backup, but it saves to a JSON file and I do not know how to open that. Copy and paste into Notepad do not record the dates and times.

    Firefox is not a way to export the history to a text file. JSON in the bookmarkbackups folder backups store only bookmarks and not history.

  • Make XY graph from the string with date and time data

    1 all sorry for my English.

    I have files with data. In this array of strings, I have 2 columns with date and time. I want to show these data to the XY Chart with time and date on some of the DBL and X on Y.

    I tried to do it by myself, but cannot add to time on X axis.

    Hi olderon,

    you date string is something like "30.01.2014" but looking for "%d//%m %y. Spot the problem?

  • My date and time settings are set in Egypt and whenever updates of the laptop with microsoft server time, it increases of 1 h.

    My date and time settings are set in Egypt and whenever updates of the laptop with microsoft server time, it increases of 1 h.
    Recently in Egypt, changes of daylight has been cancelled and I guess that's the cause of the problem!
    Any ideas?

    If time was recently cancelled, you can go to your control panel:
    Panel-> data and time-zone (tab) >
    and uncheck the "automatically adjust clock for daylight saving time.

    Otherwise, you probably need to adjust your zone settings on your computer using Microsoft time zone Editor.

    TZEdit: <> http://download.microsoft.com/download/5/8/a/58a208b7-7dc7-4bc7-8357-28e29cdac52f/tzedit.exe >

    HTH,
    JW

  • Problems with the date and time - have to reset the date & time on reboot

    original title: problems with the date and time

    Whenever I turn on my computer (Windows XP 2002) I click on F2.  Then I re - set the date and time it occurred in January 2006 1 h every time I have turn off the computer.  Can someone tell me what I need to do?

    You need to replace the battery in time clock (RTC) real of your computer.  It can also be called the CMOS or BIOS battery.

    Many computers, this battery is an inexpensive CR2032 button available in almost every pharmacy corner.  There are, however, some computers (especially laptops) that require a different (and probably more expensive) battery.

    Whatever the expense, almost all of these batteries are easy to replace.

    To get help, post back with the brand and model of your computer.

  • Passport problems of blackBerry with date and time on the passport of Blackberry

    Hello!
    I have problems with my passport for Blackberry.
    For the couple in a day time, it changes itself. So my hub doesn't work, I get no new messages, I can't send messages! The last time I did correct settings did not help. If everything is correct or hub or messages do not work. I tried to make different adjustments, tried to restart the hub, tried to restart the phone. but it does not work. I really need your help because I can't use my phone and nobody can connect with me.
    I didn't drop the phone. I know that these problems are related to the date and time because since the first problem with hub and messages has occurred, I saw that the date and time were bad, changed to correct and everything went well. I don't understand why he doesn't now. Can you tell me what to do?
    OS 10.3.2.2836
    1 January, I received this phone and it worked allright until some of the OS updates, can't tell which exactly because I have auto update.

    For those who have the same problem: I deleted the contact of my mother on the phone. I deleted the messages displayed as January 27, then I added my mother to local contacts and new messages started coming

Maybe you are looking for