Home> php教程> PHP源码> body text

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

WBOY
Release: 2016-06-08 17:30:12
Original
997 people have browsed it

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']);

}

?>

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!