首页 > 开发 > PHP > 正文

php简单数据保存程序实例

2024-05-04 21:58:55
字体:大 中 小
来源:转载
供稿:网友
  1. <form id="form1" name="form1" method="post" action=""> 
  2.   <label> 
  3.   <input type="text" name="cname" /> 
  4.   </label> 
  5.   <p> 
  6.     <label> 
  7.     <input type="text" name="caddress" /> 
  8.     </label> 
  9.   <label> 
  10.     <input type="text" name="ctel" /> 
  11.     </label> 
  12.   <label> 
  13.     <input type="text" name="cfix" /> 
  14.     </label> 
  15.   <label> 
  16.     <input type="text" name="cmail" /> 
  17.     </label> 
  18.   </p> 
  19. </form> 
  20. <?php 
  21. include(dirname(__FILE__).'./inc/gg_function.php'); 
  22.  
  23. if( $_POST) 
  24. { 
  25.  $_cname = Get_value('cname',1); 
  26.  $_address = Get_value('caddress',1); 
  27.  $_tel = Get_value('ctel',1); 
  28.  $_fix = Get_value('cfix',1); 
  29.  $_mail = Get_value('cmail',1); 
  30.   
  31.   
  32.  if( emptyempty($_cname) || strlen( $_cname )>200 ) 
  33.  { 
  34.   ShowMsg('请输入公司名称!'); 
  35.  } 
  36.  elseif( emptyempty( $_address ) || strlen( $_address )>200 ) 
  37.  { 
  38.   ShowMsg('请输入公司地址!'); 
  39.  } 
  40.  elseif( emptyempty( $_tel ) || strlen($_tel)>12 ) 
  41.  { 
  42.   ShowMsg('请输入正确的电话号码'); 
  43.  } 
  44.  elseif( emptyempty($_fix) || strlen( $_fix )>20 ) 
  45.  { 
  46.   ShowMsg('输入传真号'); 
  47.  } 
  48.  elseif( emptyempty( $_mail ) || strlen( $_mail )>254 ) 
  49.  { 
  50.   ShowMsg('输入正确的邮件地址'); 
  51.  } 
  52.  else{ 
  53.   $_sql = "Insert into gx_coo(c_name,c_address,c_tel,c_fix,c_maile)value('$_cname','$_address','$_tel','$_fix','$_mail')"; 
  54.   if( mysql_query( $_sql ) ) 
  55.   { 
  56.    ShowMsg('信息保存成功!'); 
  57.   }//开源代码Vevb.com 
  58.   else 
  59.   { 
  60.     
  61.    ShowMsg('操作失败请重试一次!'); 
  62.   } 
  63.  } 
  64. } 
  65. ?> 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表