Having Problem with Date


Posted on 16th Feb 2014 07:03 pm by admin

l have a submit buttom where user have the possibility to add a date to specify when his message should be made reachable online.

I have seen a bug which l am not having a clue to solve and l need help.

Any time a user tries to edit his text, the edit formular opens with a given dateon 1999.11.30 and a dateof of 1999.11.30

For God sake l got no clue where these date digits are coming from.
This outdated problem doesn´t allow ediiting to save well.

Enclosed is my code.

MAybe one could figure out where l am going wrong.


Thanks in advance

Code: if(isset($_POST['save'])) {
// Saving Edited Formular

$message = "";
$maintext = htmlentities($_POST['maintext']);
$shorttext = $_POST['shorttext'];
$title = htmlentities($_POST['title']);
$linked = $_POST['linked'];
$dateon = ($_POST['startdate']);
$dateoff = ($_POST['enddate']);

if($lang == "ger") {
if(! empty($dateon)) {
$on = explode(".", $dateon);
if(count($on) == 3 && checkdate($on[1], $on[0], $on[2]))
$dateon = date("Y-m-d", mktime(0, 0, 0, $on[1], $on[0], $on[2]));
else
$status = 5;
}
if(! empty($dateoff)) {
$off = explode(".", $dateoff);
if(count($off) == 3 && checkdate($off[1], $off[0], $off[2]))
$dateoff = date("Y-m-d", mktime(0, 0, 0, $off[1], $off[0], $off[2]));
else
$status = 5;

}
}
else if ($lang != "ger") {
if(!empty($dateon)) {
$on = explode(".", $dateon);
if(count($on) == 3 && checkdate($on[1], $on[2], $on[0]))
$dateon = date("Y-m-d", mktime(0, 0, 0, $on[1], $on[2], $on[0]));
else
$status = 5;
}

if(!empty($dateoff)) {
$off = explode(".", $dateoff);
if(count($off) == 3 && checkdate($off[1], $off[2], $off[0]))
$dateoff = date("Y-m-d", mktime(0, 0, 0, $off[1], $off[2], $off[0]));
else
$status = 5;
}
}
if(empty($status)) {
if(isset($parent)) {
$resDate = my_sql_query("SELECT date_on, date_off FROM navi WHERE nid=$parent", "");
if(isset($resDate[0]))
$status = 2;
$catDateOn = $resDate[1][0]['date_on'];
$catDateOff = $resDate[1][0]['date_off'];
}
if(!empty($catDateOn) && !empty($dateon) && $catDateOn > $dateon) {
$status = 7;
}
else if(!empty($catDateOff) && !empty($dateoff) && $catDateOff < $dateoff) {
$status = 8;
}
else if($dateon != "" && $dateoff != "" && $dateon > $dateoff) {
$status = 9;
}


The Html Formular

Code:
$result = my_sql_query("SELECT date_on, date_off FROM navi WHERE nid=$sel AND is_campaign IS NOT NULL","");
if(!isset($result[0])) {
#$dateon = $result[1][0]["date_on"];
#$dateoff = $result[1][0]['date_off'];
if($lang == "ger") {
if($dateon != "") {
$on = explode("-", $dateon);
if(count($on) == 3)
$dateon = date("d.m.Y", mktime(0, 0, 0, $on[1], $on[2], $on[0]));
}
if($dateoff != "") {
$off = explode("-", $dateoff);
if(count($off) == 3)
$dateoff = date("d.m.Y", mktime(0, 0, 0, $off[1], $off[2], $off[0]));
}
} else {
if($dateon != "") {
$on = explode("-", $dateon);
if(count($on) == 3)
$dateon = date("Y-m-d", mktime(0, 0, 0, $on[1], $on[2], $on[0]));
}
if($dateoff != "") {
$off = explode("-", $dateoff);
if(count($off) == 3)
$dateoff = date("Y-m-d", mktime(0, 0, 0, $off[1], $off[2], $off[0]));
}
}
}

echo "<tr>n"
."<td width='10%'></td>n"
."<td width='800px' align='center' colspan='3'><br />"._FROM."&nbsp<input name='startdate' type='text' value='$dateon' size='15' maxlength='10'>&nbsp;&nbsp;"._TO."&nbsp<input name='enddate' type='text' value='$dateoff' size='15' maxlength='10'</td>n"
."<td width='10%'></td>n"
."</tr>n"
."<tr>n"
."<td width='10%'></td>n"
."<td width='800px' align='center' colspan='3'><br /><input type='submit' name='save' value='"._SAVE."' id='button'>&nbsp;&nbsp;<input type='submit' name='reset3' value='"._RESET."' id='button'></td>n"
#."<td width='10%'></td>n"
."</tr>n";

echo "</table><br /></td></tr></table><br /><br /><br />n"
."</div>n"
."</form>n";
echo "<script>document.form1.title.focus();</script>n";
echo "<script>textCounter(document.form1.shorttext, document.form1.countChars, $numberChars);</script>";

No comments posted yet

Your Answer:

Login to answer
153 Like 53 Dislike
Previous forums Next forums
Other forums

want to add a break after a certain amount of characters
i was wondering how to add a break in a blog post after a certain amount of characters... any idea o

Date/Time and Checkbox
Hi Everyone,

I am trying to figure out how to insert the current date and tim

Facebook status update API
Hello,

So, I'm trying to create my first Facebook application with PHP.

Basic ideas fo

urldecode question
How would I format this line of code properly?

<?php echo urldecode($_GET['Title']); ?

2 things: enter doesn't work in IE & empty form
i have this search form that works well except for 2 things.

1) on IE when i hit enter instea

ASP.NET Validation Event Cycle
Hi,
I have asp button as follow:

Page doesn't expand for content
Hi. I've been testing a query I made. It's here http://lapr1.6te.net/inquerito.php
The page doesn

insert Multiple rows into the table from that table data
Hi All,

I have a requirement like to insert mulitple rows into the table from that

frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the ur

links using header()
Hi All

I'm not sure where to ask for help on this but I hope someone can offer some. I'm at

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash