21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$dbc=@mysql_connect('localhost','root','968zou95yi');
mysql_select_db('myblog',$dbc);
$problem=FALSE;
if(!empty($_POST['title']) && !empty($_POST['entry'])){
$title=mysql_real_escape_string(trim(strip_tags($_POST['title'])),$dbc);
$entry=mysql_real_escape_string(trim(strip_tags($_POST['entry'])).$dbc);
}else{
print '<p style="color:red">Please submit both a title and an entry.</p>';
$problem=TRUE;
}
if(!$problem){
$query="INSERT INTO entries(entry_id,title,entry,date_entered)
values(0,'$title','$entry',NOW())";
if(@mysql_query($query.$dbc)){
print '<p>条目已经加入</p>';
}else{
print '<p style="color:red">不能添加条目因为:</br>'.mysql_error($dbc).'</p><p>正在运行的查询是:'.$query.'.</p>';
}
print "$query";
}
mysql_close($dbc);
}
?>