Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Архив1 / docx56 / курсач(11).docx
Скачиваний:
41
Добавлен:
01.08.2013
Размер:
69.91 Кб
Скачать

Insert_admin.Php

<?php session_start(); ?>

<!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=utf-8" />

<title>Chemistry LAB - free service</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="functions.js"></script>

</head>

<body>

<div id="wrap">

<div id="header">

<h1 id="sitename">Chemistry LAB</h1>

</div>

<div id="page">

<div id="menu">

<div id="sidemenu">

<h2 align="center">Регистрация </h2>

<ul>

<?php include_once ("register.php");?>

<!-- ****************--></ul>

<ul>

<h2 align="center">Меню</h2>

<li><a href="index.php">Главная</a> </li>

<li ><a href="result.php">Сервис</a></li>

<?php

if (!empty($_SESSION['login']))

{

print<<< HERE

<li><a href="insert.php">Добавление вещества</a></li>

<li><a href="insert_ch.php">Добавление реакции</a></li>

<li><a href="del_ch.php">Удаление вещества</a></li>

<li class="active"><a href="insert_admin.php">Добавление админа</a></li>

HERE;}?>

</ul>

</div>

</div>

<div id="content">

<h2align="center">Добавить нового администратора</h2>

<form action="admin_go.php" method="GET" name="Form1">

<table width="60%" border="0" align="center">

<tr>

<td>Логин:</td>

<td><input name="login" type="text" size="50" id="l" /></td>

</tr>

<tr>

<td>Пароль:</td>

<td><input name="pass" type="password" value="" size="50" maxlength="255" id="p" /> <br /></td>

</tr>

<tr>

<td>Подтверждение пароля:</td>

<td><input name="pass" type="password" value="" size="50" maxlength="255" id="pp" /> <br /></td>

</tr>

<tr>

<td>Имя:</td>

<td><input name="name" type="text" size="50" id="n" onBlur="CheckText('n')" /><br /></td>

</tr>

<tr>

<td>Фамилия:</td>

<td><input name="surname" type="text" size="50" id="s" onBlur="CheckText('s')" /><br /></td>

</tr>

<tr>

<td>Возраст:</td>

<td><input name="age" type="text" size="50" id="a" onBlur="CheckAge('a')" /><br /></td>

</tr>

<tr>

<td>Место работы:</td>

<td><input name="work" type="text" size="50" id="w" /><br /></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="button" value="ДОБАВИТЬ" onClick="CheckEmptyAllNewAdmin()" /></td>

</tr>

</table>

</form>

</p>

</div>

<div class="clear"></div>

<div id="browse">

<h2 class="subhead"></h2>

</div>

</div>

</div>

</body>

</html>

admin_go

<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Chemistry LAB - free service</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="functions.js"></script>

</head>

<body>

<div id="wrap">

<div id="header">

<h1 id="sitename">Chemistry LAB</h1>

</div>

<div id="page">

<div id="menu">

<div id="sidemenu">

<h2 align="center">Регистрация </h2>

<ul>

<?php include_once ("register.php");?>

<!-- ****************--></ul>

<ul>

<h2 align="center">Меню</h2>

<li><a href="index.php">Главная</a> </li>

<li><a href="result.php">Сервис</a></li>

<?php

if (!empty($_SESSION['login']))

{

print<<< HERE

<li><a href="insert.php">Добавление вещества</a></li>

<li><a href="insert_ch.php">Добавление реакции</a></li>

<li><a href="del_ch.php">Удаление вещества</a></li>

<li class="active"><a href="insert_admin.php">Добавление админа</a></li>

HERE; } ?>

</ul>

</div>

</div>

<div id="content">

<h2 align="center">Новый админ</h2>

<?php

require_once("config.php");

$login = $_GET['login'];

$pass = md5($_GET['pass']);

$name= $_GET['name'];

$surname = $_GET['surname'];

$age = $_GET['age'];

$work = $_GET['work'];

$strSQL = "SELECT `id` FROM `administrators` WHERE `login`='$login'";

$rs = mysql_query($strSQL);

while($row = mysql_fetch_array($rs)) {

$t=$row['id'] ; }

mysql_query("set character_set_client='utf8'");

mysql_query("set character_set_results='utf8'");

mysql_query("set collation_connection='utf8_general_ci'");

$strSQL = "INSERT INTO `chemistry`.`administrators` (`id`, `login`, `password`, `name`, `surname`, `age`, `work`) VALUES ('', '$login', '$pass', '$name', '$surname', '$age', '$work');";

if((!mysql_query($strSQL)) or ($t!=0))

{

echo"Ошибка добавления нового администратора!";

}

elseecho"Новый администратор добавлен успешно!";

?>

</p>

</div>

<div class="clear"></div>

<div id="browse">

<h2 class="subhead"></h2>

</div></div></div></body></html>