时间:2021-07-01 10:21:17 帮助过:2人阅读
php操作mysql的代码
1 <?php 2 $con=mysql_connect("127.0.0.1","root","root"); 3 if(!$con){ 4 die(mysql_error()); 5 } 6 7 mysql_select_db("message",$con); 8 9 $name=$_POST["name"]; 10 $email=$_POST["email"]; 11 $message=$_POST["message"]; 12 $msgdate=date(‘Y-m-d‘,time()); 13 $sql=mysql_query("insert into message(name,email,information,msgdate) values(‘$name‘,‘$email‘,‘$message‘,‘$msgdate‘)",$con); 14 if(!$sql){ 15 die(mysql_error()); 16 } 17 18 mysql_close($con); 19 20 header("Location:../index.html#6"); 21 ?>View Code
php通过post将表单数据保存到数据库实例
标签: