📄 admin_addnewchk.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="hotel.asp" -->
<!--#include file="include/is_admin.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加新房间</title>
<style type="text/css">
<!--
@import url("style.css");
-->
</style>
</head>
<body>
<div align="center">
<table width="706" height="281" border="0" class="table_big">
<tr>
<td valign="top"><div align="center">
<!--#include file="include/admin_head.asp" -->
<%
dim err(3)
dim haveerr,room_name,room_type,cost,i
dim rs_add,sql
'接收表单数据--------------------
room_name=request.Form("name")
room_type=request.Form("type")
cost=request.Form("cost")
'检查数据--------------------
if len(room_name) > 30 then err(1)="房间名称不能超过30个字符"
if len(room_name) < 2 then err(1)="房间名称不能少于2个字符"
if not IsNumeric(cost) then err(2)="费用必须是数字"
if len(cost) >4 then err(3)="费用不能多于4位数"
'判断是否存在错误-----------
for i=1 to 3
if err(i)<>"" then haveerr=1
next
If haveerr=0 Then
'打开房间数据库--------------------
set rs_add=server.CreateObject("adodb.recordset")
sql = "select * from room"
rs_add.open sql,hotel_conn,3,2
'添加房间-------------
rs_add.addnew
rs_add("name")=room_name
rs_add("room_id")=room_name
rs_add("type")=room_type
rs_add("cost")=cost
rs_add.update
%>
<br>
<table width="411" border="0" class="table_small">
<tr>
<td> </td>
</tr>
<tr>
<td class="text_title"><div align="left">房间添加成功!</div></td>
</tr>
<tr>
<td class="table_title"> </td>
</tr>
<tr>
<td class="text"><div align="left">成功添加一个名称为<%= rs_add("name") %>,类型为<%= rs_add("type") %>,花费为<%= rs_add("cost") %>元的房间</div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<% Else %>
<br>
<table width="416" border="0" class="table_small">
<tr>
<td> </td>
</tr>
<tr>
<td class="text_title"><div align="left">发现以下错误:</div></td>
</tr>
<tr>
<td class="table_title"> </td>
</tr>
<tr>
<td class="text_error"><div align="left">
<%
for i=1 to 3
if err(i) <> "" then response.Write("●" & err(i) & "<br>")
next
%>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<% End If %>
<br>
</div></td>
</tr>
</table>
</div>
</body>
<%
set rs_add=nothing
%>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -