데이터를 MySQL 데이터베이스에 제출하는 양식을 만들었지 만 날짜, 시간, 연도 및 월 필드는 언제 같은 날짜 (1970 년 1 월 1 일)로 되 돌린다. 양식에 현재 날짜, 시간 등이 표시되는 정보를 데이터베이스에 제출합니다. 시간과 날짜 필드에 자동으로 현재 시간과 날짜가 표시되도록 이미 설정했습니다. 누군가 나를 도와주세요.양식을 MySQL 데이터베이스에 제출하는 중
형태 : 게시물이 타임 스탬프없이 제출되고, 디폴트의 타임 스탬프로 되돌아 몇 가지 이유로
<html>
<head>
<title>Ultan's Blog | New Post</title>
<link rel="stylesheet" href="css/newposts.css" type="text/css" />
</head>
<body>
<div class="new-form">
<div class="header">
<a href="edit.php"><img src="images/edit-home-button.png"></a>
</div>
<div class="form-bg">
<?php
if (isset($_POST['submit'])) {
$month = htmlspecialchars(strip_tags($_POST['month']));
$date = htmlspecialchars(strip_tags($_POST['date']));
$year = htmlspecialchars(strip_tags($_POST['year']));
$time = htmlspecialchars(strip_tags($_POST['time']));
$title = htmlspecialchars(strip_tags($_POST['title']));
$entry = $_POST['entry'];
$timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);
$entry = nl2br($entry);
if (!get_magic_quotes_gpc()) {
$title = addslashes($title);
$entry = addslashes($entry);
}
mysql_connect ('localhost', 'root', 'root') ;
mysql_select_db ('tmlblog');
$sql = "INSERT INTO php_blog (timestamp,title,entry) VALUES ('$timestamp','$title','$entry')";
$result = mysql_query($sql) or print("Can't insert into table php_blog.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
print "<p class=\"success\">Your entry has successfully been entered into the blog. </p>";
}
mysql_close();
}
?>
<?php
$current_month = date("F");
$current_date = date("d");
$current_year = date("Y");
$current_time = date("H:i");
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="month" value="<?php echo $current_month; ?>" />
<input type="text" name="date" value="<?php echo $current_date; ?>" />
<input type="text" name="year" value="<?php echo $current_year; ?>" />
<input type="text" name="time" id="time" size="5"value="<?php echo $current_time; ?>" />
<input class="field2" type="text" id="title" value="Title Goes Here." name="title" size="40" />
<textarea class="textarea" cols="80" rows="20" name="entry" id="entry" class="field2"></textarea>
<input class="field" type="submit" name="submit" id="submit" value="Submit">
</form>
</div>
</div>
</div>
<div class="bottom"></div>
<!-- //End Wrapper!-->
</body>
</html>
</html>
alt text http://i42.tinypic.com/2ns4755.jpg
.
이 질문을 업데이트했습니다. 새로운 정보를 확인하십시오 ... 제발 도와주세요. –
그러나 양식을 수정하지 않았습니다. 그것을 고친 후 내 컴퓨터에서 코드를 실행했고 올바른 타임 스탬프가 생성되었습니다. – Mike
여기에 코드를 수정하지 않았지만 타임 스탬프가 '0'인 방법을 보여주는 이미지를 추가했습니다. 내 컴퓨터에 코드를 수정했습니다. 양식을 업데이트했지만 정확한 타임 스탬프로 내 블로그에 제출하지 않았습니다. –