Отчет по диплому (1221123), страница 7
Текст из файла (страница 7)
}
?>!</span></div>
<div id="wb_Logout1" style="position:absolute;left:90px;top:50px;width:90px;height:20px;z-index:3;">
<form name="logoutform" method="post" action="<?php echo basename(__FILE__); ?>" id="logoutform">
<input type="hidden" name="form_name" value="logoutform">
<input class="logoutform_button" type="submit" name="logout"value="Выйти" id="logout" style="width:90px;height:20px;" />
</form>
</div>
</div>
</div>
<div id="Layer2" style="position:absolute;text-align:center;left:3%;top:0px;width:6%;height:90px;z-index:35;" title="">
<div id="Layer2_Container" style="width:80px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="wb_Image1" style="position:absolute;left:10px;top:10px;width:60px;height:68px;z-index:4;">
<a href="./index.php"><imgsrc="images/dfc85d1c9bdf7162207ac35f83b4544f.png" id="Image1" alt="" style="width:60px;height:68px;"></a></div>
</div>
</div>
</body>
</html>
ПРИЛОЖЕНИЕ Б
(справочное)
Исходный код файла reg.php (регистрация пользователей)
<?php
$mysql_server = 'localhost';
$mysql_username = 'webtechsup';
$mysql_password = '3q4q65pr';
$mysql_database = 'webtechsup';
$mysql_table = 'users';
$success_page = '';
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
$newusername = $_POST['username'];
$newemail = $_POST['email'];
$newpassword = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$newfullname = $_POST['fullname'];
$code = 'NA';
if ($newpassword != $confirmpassword)
{
$error_message = 'Паролинесовпадают';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$]{1,50}$/", $newusername))
{
$error_message = 'Логин занят, придемайте другой';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$]{1,50}$/", $newpassword))
{
$error_message = 'Неверный пароль. Повторите ввод';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$.' &]{1,50}$/", $newfullname))
{
$error_message = 'Недействительноеимя, повторитеввод';
}
else
if (!preg_match("/^.+@.+\..+$/", $newemail))
{
$error_message = 'Введите e-mail заного';
}
if (empty($error_message))
{
$db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
if (!$db)
{
die('Failed to connect to database server!<br>'.mysql_error());
}
mysql_select_db($mysql_database, $db) or die('Failed to select database<br>'.mysql_error());
$sql = "SELECT username FROM ".$mysql_table." WHERE username = '".$newusername."'";
$result = mysql_query($sql, $db);
if ($data = mysql_fetch_array($result))
{
$error_message = 'Это имя уже занято. Придумайтедругое';
}
}
if (empty($error_message))
{
$crypt_pass = md5($newpassword);
$newusername = mysql_real_escape_string($newusername);
$newemail = mysql_real_escape_string($newemail);
$newfullname = mysql_real_escape_string($newfullname);
$sql = "INSERT `".$mysql_table."` (`username`, `password`, `fullname`, `email`, `active`, `code`) VALUES ('$newusername', '$crypt_pass', '$newfullname', '$newemail', 1, '$code')";
$result = mysql_query($sql, $db);
mysql_close($db);
$subject = 'new account';
$message = 'Новыйпользователь';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\nPassword: ";
$message .= $newpassword;
$message .= "\r\n";
$header = "From: website"."\r\n";
$header .= "Reply-To: website"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();
mail($newemail, $subject, $message, $header);
mail('web.techsup@gmail.com', $subject, $message, $header);
header('Location: '.$success_page);
exit;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Регистрация</title>
<style type="text/css">
div#container
{
width: 313px;
position: relative;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align: left;
}
body
{
text-align: center;
margin: 0;
background-color: #FFFFFF;
color: #000000;
}
</style>
<style type="text/css">
a
{
color: #0000FF;
text-decoration: underline;
}
a:visited
{
color: #800080;
}
a:active
{
color: #FF0000;
}
a:hover
{
color: #0000FF;
text-decoration: underline;
}
</style>
<style type="text/css">
.signupform_table
{
background-color: #EEEEEE;
border-color:#878787;
border-width:1px;
border-style: solid;
color: #000000;
font-family: Arial;
font-size: 13px;
text-align: right;
border-spacing: 4px;
}
.signupform_header
{
background-color: #878787;
color: #FFFFFF;
text-align: center;
}
.signupform_text
{
background-color: #FFFFFF;
border-color: #878787;
border-width: 1px;
border-style: solid;
color: #000000;
font-family: Arial;
font-size: 13px;
}
.signupform_button
{
background-color: #FFFFFF;
border-color: #878787;
border-width: 1px;
border-style: solid;
color: #000000;
font-family: Arial;
font-size: 13px;
}
</style>
</head>
<body>
<div id="container">
<div id="wb_Signup1" style="position:absolute;left:0px;top:0px;width:277px;height:202px;text-align:right;z-index:0;">
<form name="signupform" method="post" action="<?php echo basename(__FILE__); ?>" id="signupform">
<input type="hidden" name="form_name" value="signupform">
<table class="signupform_table" style="width:277px;height:202px;">
<tr>
<td class="signupform_header" colspan="2" style="height:20px;">Регистрация</td>
</tr>
<tr>
<td style="height:20px">Имя:</td>
<td style="text-align:left"><input class="signupform_text" name="fullname" type="text" id="fullname" style="width:150px;height:18px;"></td>
</tr>
<tr>
<td style="height:20px">Логин:</td>
<td style="text-align:left"><input class="signupform_text" name="username" type="text" id="username" style="width:150px;height:18px;"></td>
</tr>
<tr>
<td style="height:20px;">Пароль:</td>
<td style="text-align:left"><input class="signupform_text" name="password" type="password" id="password" style="width:150px;height:18px;"></td>
</tr>
<tr>
<td style="height:20px">Повторитепароль:</td>
<td style="text-align:left"><input class="signupform_text" name="confirmpassword" type="password" id="confirmpassword" style="width:150px;height:18px;"></td>
</tr>
<tr>
<td style="height:20px">E-mail:</td>
<td style="text-align:left"><input class="signupform_text" name="email" type="text" id="email" style="width:150px;height:18px;"></td>
</tr>
<tr>
<td colspan="2"><?php echo $error_message; ?></td>
</tr>
<tr>
<td> </td><td style="text-align:left;vertical-align:bottom"><input class="signupform_button" type="submit" name="signup" value="Регистрация" id="signup" style="width:90px;height:20px;"></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
ПРИЛОЖЕНИЕ В
(обязательное)
Код отправки заказа на почту и код проверки заполнения полей:
<?php
functionValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
returnpreg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$mailto = 'web.techsup@gmail.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Zakaz';
$message = 'id1665';
$success_url = './uspeh.html';
$error_url = '';
$error = '';
$eol = "\n";
$max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}
if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$internalfields = array ("submit", "reset", "send", "captcha_code");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .=ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .=ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
















