⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newproduct.php

📁 一个php的公司信息系统
💻 PHP
字号:
<?
  require('session.inc');
  require('connect.inc');
  if ($usern!=-1)
  {
    html_header("非法登录,拒绝访问 - ACCESS DENIED",'<META http-equiv="refresh" content="3; url=index.php">');
    echo "<td align=right valign=center><br>
    Sorry, 您正想非法登录本系统,请正常登录!<br>系统会在3秒后自动返回登录页面。
    <br><br><br><a href=index.php>返回登录</a></td>";
    html_footer();
  }
  else
  {
?>
<html>
<head>
<title>::: DATABASE 化妆品公司数据库管理系统 - 新增产品 :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="common.css" type="text/css">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center" height="450">
  <tr>
    <td background="images/bg2.jpg">
      <table width="770" border="0" cellspacing="0" cellpadding="0" height="450">
        <tr>
           <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" height="450">
              <tr>
                <td height="140" class="bigh"> <font color=#ff3333>新增产品</font></td>
              </tr>
              <tr>
                <td valign=top>
<?
  if ($step!=1)
  {
?>
                  <table width="48%" border="0" cellspacing="0" cellpadding="0" align="right">
                    <tr>
                      <td>
                        <form name="form1" method="post" action="newproduct.php?step=1">
                          <p><b>请填写产品纪录</b></p>
                          <table width="100%" border="0" cellspacing="3" cellpadding="0">
                            <tr>
                              <td width="33%">产品号
                                <input type="text" name="pid" size="8" maxlength="8">
                              </td>
                              <td width="33%">商 标
                                <input type="text" name="mark" size="8" maxlength="20">
                              </td>
                              <td>货品类别
                                <input type="text" name="class" size="8" maxlength="10">
                              </td>
                            </tr>
                            <tr>
                              <td width="33%">产品名
                                <input type="text" name="pname" size="8" maxlength="20">
                              </td>
                              <td width="33%">批发价
                                <input type="text" name="pprice" size="8" maxlength="11">
                              </td>
                              <td>零 售 价
                                <input type="text" name="sprice" size="8" maxlength="11">
                              </td>
                            </tr>
                            <tr>
                              <td width="33%">单 位
                                <input type="text" name="unit" size="4" maxlength="4">
                              </td>
                              <td width="33%">颜 色
                                <input type="text" name="color" size="8" maxlength="10">
                              </td>
                              <td>有 效 期
                                <input type="text" name="life" size="4" maxlength="4">
                                月</td>
                            </tr>
                            <tr>
                              <td colspan="3">备注<br>
                                <div align=center>
                                  <textarea name="memo" cols="56" rows="5"></textarea>
                                </div>
                              </td>
                            </tr>
                          </table>
                          <p>
                            <input type="submit" name="Submit" value="新增产品" onClick="MM_validateForm('pid','','RisNum','mark','','R','class','','R','pname','','R','pprice','','RisNum','sprice','','RisNum','unit','','R','color','','R','life','','RisNum');return document.MM_returnValue">
                               
                            <input type="reset" name="reset" value="重置表单">   <a href=index2.php>返回首页</a>
                          </p>
                        </form>
                      </td>
                    </tr>
                  </table>
<?
  }
  else
  {
    $str_sql="select pid from PRODUCTTB where pid = '$pid';";
    $result=mysql_db_query($db,$str_sql,$link_id);
    if (!$result) html_error_exit('MySQL查询命令失败!');
    else
    {
      $num=@mysql_num_rows($result);
      if ($num>0)
      {
        echo "<div align=right><br>产品ID号已经存在,不能重复,请重新填写
        <br><br><br><a href=newproduct.php?step=0>返回重新填写</a></div>";
      }
      else
      {
        $str_sql="insert into PRODUCTTB values (
                  '$pid',
                  '$mark',
                  '$class',
                  '$pname',
                  '$pprice',
                  '$sprice',
                  '$color',
                  '$life',
                  '$unit',
                  '$memo');";
        $result=mysql_db_query($db,$str_sql,$link_id);
        if (!$result) html_error_exit('MySQL查询命令失败!');
        else
        {
          echo "<div align=right><br>新增产品成功,信息如下:<br><table border=0 width=40%><tr><td>
          <li>产 品 ID - $pid
          <li>产品商标 - $mark
          <li>产品类别 - $class
          <li>产 品 名 - $pname
          <li>批 发 价 - $pprice
          <li>零 售 价 - $sprice
          <li>单  位 - $unit
          <li>颜  色 - $color
          <li>有 效 期 - $life 月
          <li>备  注 - <br> $memo
          </td></tr></table>
          <br><br><br><a href=newproduct.php?step=0>返回继续新增</a>    <a href=index2.php>返回首页</a></div>";
        }
      }
    }
  }
  @mysql_close($link_id);
?>
                </td>
              </tr>
              <tr>
                <td height="40">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="40">
                    <tr>
                      <td valign="bottom" align="right"><font face="Arial"><b>Powered
                        by <img src="images/php.gif" width="39" height="20" align="absmiddle">
                        &amp; <img src="images/mysql.gif" width="82" height="20" align="absmiddle"></b></font></td>
                      <td align="right" valign="bottom" width="200"><font face="Arial">&copy;
                        <a href="mailto:lonelyp@etang.com">Lonely Passenger</a>,2001<br>
                        All rights reserved!</font></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?
  }
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -