<html>
<body ><meta charset=
"utf-8"
>
<form action=
''
method=
'post'
>
标题:<input type=
'text'
name=
'text'
><br>
内容:<textarea name=
'te'
cols=
'20'
rows=
'3'
></textarea>
<select name=
"check"
>
<option value=
'谢谢您'
>谢谢您</option>
<option value=
'您好'
>您好</option>
<option value=
'再见'
>再见</option>
</select><br>
<p> </p>
<input type=
'submit'
name=
'sub'
value=
'确定'
>
<input type=
'reset'
name=
'res'
value=
'重置'
>
</form>
<?php
function
str(
$str
){
$str
= preg_replace(
"/ /"
,
" "
,
$str
);
$str
= preg_replace(
"/cha(13)/"
,
"<br>"
,
$str
);
echo
"内容:"
.
$str
;
}
if
(!
empty
(
$_POST
[
"sub"
])){
if
(
$_POST
[
"text"
] ==
""
|| ((
$_POST
[
"te"
] ==
""
) && (
$_POST
[
"check"
] == 1))){
echo
"<script>alert('内容不能为空');location.href='index.php'</script>"
;
}
else
{
if
(!
empty
(
$_POST
[
"check"
]) ||
$_POST
[
"select"
] !=
'1'
){
echo
"<br>标题:"
.
$_POST
[
"text"
].
"<br>"
;
str(
$_POST
[
"te"
].
$_POST
[
"check"
]);
}
else
{
echo
"标题:"
.
$_POST
[
"text"
].
"<br>"
;
str(
$_POST
[
"te"
]);
}
echo
"<br>"
;
echo
"发表时间:"
;
date_default_timezone_set(
"Asia/ShangHai"
);
echo
date
(
"Y-m-d H:i:s"
).
"<br>"
;
$time
=time();
$time_r
=
strtotime
(
"1 August 2014"
);
echo
"距离销毁还有:"
.
ceil
(((
$time_r
-
$time
)/(3600*24))).
"天"
;
}
}
?>
</body>
</html>