<?php
//1.
$content=$_REQUEST['content'];
$userName=$_REQUEST['userName'];
$phone=$_REQUEST['phone'];
$pubTime=$_REQUEST['pubTime'];
//查询字符串
//user/login?username=jack&age=18
// http://127.0.0.1/day05/ifeng_new.php?content=aaaa&userName=zhangsan&phone=12345678901&pubTime=2018-10-30
//1.连接数据库、
$conn=mysqli_connect('127.0.0.1','root','','ifeng',3306);
//2.设置编码
$sql="SET NAMES UTF8";
mysqli_query($conn,$sql);
//3.执行插入语句
$sql="INSERT INTO comment VALUES(NULL,'$content','$userName','$phone','$pubTime')";
$result=mysqli_query($conn,$sql);
var_dump($result);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action='ifeng_new.php'>
<p>
内容:<input type="" name="content">
</p>
<p>
用户名: <input type="" name="userName">
</p>
<p>
手机: <input type="" name="phone">
</p>
<p>
发布日期: <input type="" name="pubTime">
</p>
<p>
<input type="submit" name="" value='提交'>
</p>
</form>
</body>
</html>
网友评论