发布网友 发布时间:2022-04-21 23:47
共2个回答
懂视网 时间:2022-04-09 15:07
<form id="contact-form" method="POST" action="../php/msg.php"> 2 <input type="text" class="form-control" name="name" placeholder="name" id="name" required /> 3 <input type="email" class="form-control" name="email" placeholder="E-mail" id="email" required /> 4 <textarea class="form-control" name="message" rows="5" placeholder="message" id="messages" required></textarea> 5 <button type="submit" class="btn btn-default">submit</button> 6 </form> View Codephp操作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将表单数据保存到数据库实例
标签:
热心网友 时间:2022-04-09 12:15
看你的表格,只需要从表单中循环取出所有行,然后依次写入数据库就行了