Jump to content

Recommended Posts

I'm trying to set the year month and day to the server on mysql in one field but am having trouble doing so. Here is my code so far

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "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>Untitled Document</title>

</head>

 

<body>

<?php

  // process form

 

 

 

  include("connectDB.php");

 

  $date = $_POST['year'].$_POST['month'].$_POST["day"];

 

  $sql = "INSERT INTO reminder(eventName, eventNote, date, hour, min, amPM) VALUES ('{$_REQUEST['eventName']}','{$_REQUEST['eventNote']}','{$_REQUEST['date']}','{$_REQUEST['hour']}','{$_REQUEST['min']}','{$_REQUEST['amPM']}')";

 

 

  $result = mysql_query($sql) or die("Sorry, please enter your correct informaiton \n");;

 

  echo "Thank You! Your information has been submitted";

 

 

?>

</body>

</html>

What I am trying to set up is an event reminder. The user will be able to set a year month and day for a email reminder about the event. I am trying to upload the year month and day using type DATE on the MYSQL server. I have three drop down menus to set the year month and day. I want it so that when they submit the form it gets submitted as one field on the database in the type DATE format which is yyyy/mm/dd.

I see.

 

Why don't you use PHP/MySQL date functions as opposed to drop downs?

 

You can also use date pickers to make it easier.

 

Google date pickers, you will find some.

 

Otherwise

 

Do something like:

 

 

$year = $_POST['year'];

 

$month = $_POST['month'];

 

$day = $_POST['day'];

 

Then a new variable for concatenation

 

$reminderdate = $year.$month.$day;

 

$reminderdate  is what you save in the DB

 

 

 

i do the same thing in some pages... it's as simple as:

 

$reminderDate = $_REQUEST['year'] . '-' . $_REQUEST['month'] . '-' . $_REQUEST['day'];

 

and then using that value in your SQL. be sure to set the values of the month and day dropdowns to zero-padded values. for instance, january is 01, february is 02, etc.

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.