📄 addroom.php
字号:
<?
include('../include/admin_or_user.php');
require_once('../include/connectionadmin.php');
require_once('../include/sqlfuns.php');
if(isset($_POST['s'])&&$_POST['s']=="增加")
{
if(findindb($conn,"room_number","room",$_POST['room_number'],"text"))
{ ?>
<script>
alert("房间号已在数据库中!");
window.history.back();
</script>
<? exit;
}
$insertsql = sprintf("INSERT INTO room (room_number, room_level,room_person) VALUES(%s, %s,%s)",
GetSQLValueString($_POST['room_number'], "text"),
GetSQLValueString($_POST['room_level'], "int"),
GetSQLValueString($_POST['room_person'], "int"));
if(isset($_GET['add'])&&$_GET['add']==1)
{
if(findindb($conn,"room_level","roomlevel",$_POST['room_level'],"int"))
{ ?>
<script>
alert("房间号已在数据库中!");
window.history.back();
</script>
<? exit;
}
$insertsql = sprintf("INSERT INTO roomlevel (room_level, room_prise, room_introduction) VALUES(%s, %s, %s)",
GetSQLValueString($_POST['room_level'], "int"),
GetSQLValueString($_POST['room_prise'], "int"),
GetSQLValueString($_POST['room_introduction'], "text"));
$insertsql1=sprintf("insert into room (room_number,room_level) values(%s,%s)",
GetSQLValueString($_POST['room_number'], "text"),
GetSQLValueString($_POST['room_level'], "int"));
$result1=odbc_exec($conn,$insertsql1);
}
$result=odbc_exec($conn,$insertsql);
if($result)
{ echo "<p> </p>";
echo "<p align=center>增加成功</p>";
}
else
{echo "<p> </p>";
echo "<p align=center>操作失败</p>";
}
odbc_close($conn);
exit;
}
$selectsql="select room_level from roomlevel order by room_level";
$selectresult=odbc_exec($conn,$selectsql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="css/hotel.css" rel="stylesheet" type="text/css" />
<link href="../css/hotel.css" rel="stylesheet" type="text/css" />
</head>
<? require('../include/check.inc');?>
<body>
<table width="100%" border="1">
<tr>
<td>
<form id="form" name="form" method="post" action="" onSubmit="return (empty(room_level)&&empty(room_number)&&numbercheck(room_level))">
<table width="60%" border="0" align="left">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
<td>增加房间</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="right"> 房间号码:</div></td>
<td><label>
<input name="room_number" type="text" id="room_number" size="13" maxlength="13" />
*</label></td>
</tr>
<tr>
<td><div align="right"> 可入住人数:</div></td>
<td><label>
<input name="room_person" type="text" id="room_person" size="3" maxlength="6" />
人
*</label></td>
</tr>
<tr>
<td><div align="right">房间星级:</div></td>
<? if(isset($_GET['add'])&&$_GET['add']==1) { ?>
<td><label>
<input name="room_level" type="text" id="room_level" size="4" maxlength="10" />
*
现有星级房间:<? if(!odbc_fetch_row($selectresult,"1")) echo "暂无记录!";
do{
echo odbc_result($selectresult,'room_level');echo " ";
}while(odbc_fetch_row($selectresult)); ?></label></td>
<? } else {?>
<td><label>
<select name="room_level" id="room_level">
<option value="">请选择</option>
<? while(odbc_fetch_row($selectresult)){ ?>
<option value="<? echo odbc_result($selectresult,'room_level');?>"><? echo odbc_result($selectresult,'room_level');?></option>
<? }?>
</select>
*
</label>
<input name="add" type="button" id="add" value="增加房间星级" onClick="location=('addroom.php?add=1')" /> </td>
<? }?>
</tr>
<? if(isset($_GET['add'])&&$_GET['add']==1) { ?>
<tr>
<td><div align="right">房间价格:</div></td>
<td><label>
<input name="room_prise" type="text" id="room_prise" size="4" maxlength="10" />
/天/人</label></td>
</tr>
<tr>
<td><div align="right">房间介绍:</div></td>
<td><label>
<textarea name="room_introduction" cols="26" rows="6" id="room_introduction"></textarea>
</label></td>
</tr>
<? }?>
<tr>
<td> </td>
<td height="60"><label>
<input name="s" type="submit" id="s" value="增加" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label></td>
</tr>
<tr>
<td> </td>
<td height="60"><p align="left" > <a href="#" onClick="window.history.back();">返回</a></p></td>
</tr>
</table>
</form></td>
</tr>
</table>
<script>
/*
function maxlevel(number)
{
if(number.value<<? echo odbc_result($selectresult,'room_level');?>||number.value==<? echo odbc_result($selectresult,'room_level');?>)
{
alert("星级房间已在数据库中!");
return false;
}
else
return true;
}*/
</script>
<p \>
<script src="../copyright.inc">
</script>
</body>
</html>
<? odbc_close($conn);?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -