Home  >  Article  >  php教程  >  php简单数据保存程序实例

php简单数据保存程序实例

WBOY
WBOYOriginal
2016-05-25 16:40:39871browse

<form id="form1" name="form1" method="post" action=""> 
  <label> 
  <input type="text" name="cname" /> 
  </label> 
  <p> 
<label> 
<input type="text" name="caddress" /> 
</label> 
  <label> 
<input type="text" name="ctel" /> 
</label> 
  <label> 
<input type="text" name="cfix" /> 
</label> 
  <label> 
<input type="text" name="cmail" /> 
</label> 
  </p> 
</form>
<?php
include (dirname(__FILE__) . &#39;./inc/gg_function.php&#39;);
if ($_POST) {
    $_cname = Get_value(&#39;cname&#39;, 1);
    $_address = Get_value(&#39;caddress&#39;, 1);
    $_tel = Get_value(&#39;ctel&#39;, 1);
    $_fix = Get_value(&#39;cfix&#39;, 1);
    $_mail = Get_value(&#39;cmail&#39;, 1);
    if (emptyempty($_cname) || strlen($_cname) > 200) {
        ShowMsg(&#39;请输入公司名称!&#39;);
    } elseif (emptyempty($_address) || strlen($_address) > 200) {
        ShowMsg(&#39;请输入公司地址!&#39;);
    } elseif (emptyempty($_tel) || strlen($_tel) > 12) {
        ShowMsg(&#39;请输入正确的电话号码&#39;);
    } elseif (emptyempty($_fix) || strlen($_fix) > 20) {
        ShowMsg(&#39;输入传真号&#39;);
    } elseif (emptyempty($_mail) || strlen($_mail) > 254) {
        ShowMsg(&#39;输入正确的邮件地址&#39;);
    } else {
        $_sql = "Insert into gx_coo(c_name,c_address,c_tel,c_fix,c_maile)value(&#39;$_cname&#39;,&#39;$_address&#39;,&#39;$_tel&#39;,&#39;$_fix&#39;,&#39;$_mail&#39;)";
        if (mysql_query($_sql)) {
            ShowMsg(&#39;信息保存成功!&#39;);
        } else {
            ShowMsg(&#39;操作失败请重试一次!&#39;);
        }
    }
}
?>


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