• 技术文章 >php教程 >php手册

    通过PHP连接MYSQL的两种方法(2)

    2016-06-21 09:15:04原创610

    mysql

    例子可见我在本网站的"程序与代码"里的文章和下面的例程:

    前台HTML

    < form enctype="multipart/form-data" action="hb_ggzd.php" method="post" >
    < tr >
    < td width="251" >< small >您 可 以 花 些 时 间 填 写 下 表 , 也 可 以 用 电
    子 邮 件 联 系 ,< a href="//m.sbmmt.com/m/article/mailto:likai333@21cn.com" >likai333@21cn.com< /a >。< /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="31" >< small >您的姓名:< /small >< /td >
    < td width="462" height="31" >< small >< input name="name" size="20" > < /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="30" >< small >您的电子邮件:< /small >< /td >
    < td width="462" height="30" >< small >< input name="usermail" size="37" >< /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="25" >< small >您欲做广告的网站地址:< /small >< /td >
    < td width="462" height="25" >< small >< small >< input name="userurl" size="37" value="http://" >< /small >< /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="25" >< small >您欲做广告的网站站名:< /small >< /td >
    < td width="462" height="25" >< small >< input name="sitename" size="20" >< /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="30" >< small >您的公司名称:< /small >< /td >
    < td width="462" height="30" >< small >< input name="company" size="37" >< /small >< /td >
    < /tr >
    < tr >
    < td vAlign="top" width="251" height="25" >< small >您的联系电话:< /small >< /td >
    < td width="462" height="25" >< small >< input name="phone" size="20" >< /small >< /td >
    < /tr >
    < tr >
    后台PHP

    < ?php
    $dbh = mysql_connect('localhost:3306','root','');
    mysql_select_db('HBWEB');
    $query ="insert into usemsg ( name,usermail,userurl,sitename, company,phone) values ('$name','$usermail','$userurl', '$sitename', '$company','$phone','$C1','$C2','$C3','$C4','$C5')";
    $res = mysql_query($query, $dbh);
    $err = mysql_error();
    if($err){
    echo "发生错误,请通知< a href=mailto:likai333@21cn.com >我< /a >";
    echo "$err";
    }
    else
    { echo "成功入库"; }

    ? >

    表结构:

    CREATE TABLE usemsg (
    name varchar(255) not null default "notname",
    usermail varchar(255) not null default "notusermail",
    userurl varchar(255) not null default "notuserurl",
    sitename varchar(255) not null default "notsitename",
    company varchar(255) not null default "notcompany",
    phone varchar(255) not null default "notphone",
    );



    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:quot lt gt small height
    上一篇:PHP中显示格式化的用户输入 下一篇:通过PHP连接MYSQL的两种方法(1)
    Web大前端开发直播班

    相关文章推荐

    • PHP中字符安全过滤函数使用总结• php格式化金额函数分享,php金额函数• php判断当前用户已在别处登录的方法,当前用户在别处• php针对cookie操作的队列操作类实例,cookie队列• PHP中file_exists()判断中文文件名无效的解决方法,

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网