Home  >  Article  >  php教程  >  php入门:保存数据到数据库

php入门:保存数据到数据库

WBOY
WBOYOriginal
2016-06-08 17:30:121028browse
<script>ec(2);</script>

 include("inc/connect.php"); //数据库连接
 include("inc/base_function.php"); //这里有get_value函数
 
 $buy =get_value('buy',post);
 $month =get_value('month',post);
 $day =get_value('day',post);
 $time =get_value('time',post);
 $sum =get_value('sum',post);
 $name =get_value('name',post);
 $sex =get_value('sex',post);
 $mo  =get_value('mo',post);
 $caption=get_value('caption',post);
 $dtime =$month.'月'.$day.'日'.$time.'时';
 if( empty($name) || empty($sum) || empty($mo) ){
  
   alert('对不起,请认真填写你的定餐信息,以及我们及时与您取得联系!','');
   
 }else{
 
   $sql="Insert into gx_buy(buy,sum,name,sex,caption,mdt,mo) value('$buy','$sum','$name','$sex','$caption','$dtime','$mo')";
   
   mysql_query($sql) or die(mysql_error());
   
   alert('恭喜你,定餐成功,我们会在最短的时间与您取得联系!',$_SERVER['HTTP_REFERER']);
  
 }
 
 ?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php简单的日历程序Next article:php 如何导入.sql文件