代码如下 | 复制代码 |
if( $_post) { $host = 'localhost'; $user_name = 'root'; $password = 'admin'; $name = $_post['user_name']; $city = $_post['city']; if(empty($name) || trim($name)=='') { echo '请填写用户名!网页特效:histryback();">返回'; exit; } $conn = mysql_connect($host,$user_name,$password); if(!$conn) { die('数据库连接失败:'.mysql_error()); } mysql_select_db('test'); $sql = "insert into users set id=7,name='" . $name . "',city='" . $city . "',created_time=now()"; mysql_query($sql) or die(" error: ".mysql_error()." sql:".$sql); mysql_close($conn); echo '数据插入成功,打开查看数据'; } |
?>
提交用户信息
代码如下 | 复制代码 |