Home php教程 php手册 php简单数据保存程序实例

php简单数据保存程序实例

May 25, 2016 pm 04:40 PM

<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>
Copy after login
<?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;);
        }
    }
}
?>
Copy after login


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1255
24