Мы поможем в написании ваших работ!



ЗНАЕТЕ ЛИ ВЫ?

Санкт-петербургский колледж информационых технологий

 

Комитет по образованию Правительства Санкт-Петербурга

САНКТ-ПЕТЕРБУРГСКИЙ КОЛЛЕДЖ ИНФОРМАЦИОНЫХ ТЕХНОЛОГИЙ

Отчет по учебной практике

МДК 03.02 Инструментальные средства разработки ПО

Тема: «Создание интернет-магазина «Муз Торг»»

 

Выполнил

студент группы 313

Филатов Александр

Проверила Алексеева Н.Н.

Оценка ________

Санкт-Петербург, 2014

Постановка задачи

Разработать функциональный интернет-магазин по продаже техники.

Теоретическая часть

Для разработки данного интернет-магазина были использованы:

- Язык разметки HTML;

- Каскадные таблицы стилей CSS;

- Языки программирования PHP.

Выполнение работы

Создание базы данных

Для обеспечения функциональных возможностей сайта была создана база данных «Basa» (Рис.1). База данных создавалась при помощи СУБД PhpMyAdmin.

Рис.1

Затем, для регистрации и учёта пользователей, в БД была создана таблица «register» (Рис.2).

Рис.2

Создание форм для регистрации и входа

Для реализации взаимодействия сайта и базы данных было создано 2 файла:

- reg.php

<?php

$db = mysql_connect ("127.0.0.1","root");

mysql_select_db ("Basa",$db);

 

          if (isset($_POST['Login'])) { $login = $_POST['Login']; if ($login == '') { unset($login);} }

if (isset($_POST['Pass'])) { $pass=$_POST['Pass']; if ($pass =='') { unset($pass);} }

          if (isset($_POST['Email'])) { $email=$_POST['Email']; if ($email =='') { unset($email);} }

 

          $login = $_POST['Login'];

          $pass = $_POST['Pass'];

          $email = $_POST['Email'];

                              

          if (empty($login) or empty($pass) or empty($email))

{

          setcookie("RegisterError", "Вы оставили пустые поля.",time()+1);

          header( 'Location: /HTML/Glav.php', true, 303 );

          exit ();

}

 

$login = stripslashes($login);

  $login = htmlspecialchars($login);

          $pass = stripslashes($pass);

$pass = htmlspecialchars($pass);

          $email = stripslashes($email);

$email = htmlspecialchars($email);

              

$login = trim($login);

$pass = trim($pass);

          $email = trim($email);

              

          $result = mysql_query("SELECT ID FROM register WHERE Login='$login'",$db);

          $myrow = mysql_fetch_array($result);

              

              

if (!empty($myrow['ID'])) {

          setcookie("RegisterError", "Пользователь с таким логином уже существует.",time()+1);

          header( 'Location: /HTML/6strun.php', true, 303 );

exit ();

}

$result2 = mysql_query ("INSERT INTO register (Login,Pass,Email) VALUES('$login','$pass','$email')");

              

if ($result2=='TRUE')

{

          setcookie("RegisterError", "Регистрация прошла успешно.",time()+1);

          header( 'Location: /HTML/6strun.php', true, 303 );

}

          else {

          setcookie("RegisterError", "Произошла ошибка при регистрации.",time()+1);

          header( 'Location: /HTML/6strun.php', true, 303 );

}        

?>

- sig.php

<?php

           if (isset($_POST['exit']))

           {

           setcookie("login", "");

           header( 'Location: /HTML/6strun.php', true, 303 );              

           exit();

           }

           else

           {

$db = mysql_connect ("127.0.0.1","root");

mysql_select_db ("Basa",$db);

 

           if (isset($_POST['Logine'])) { $login = $_POST['Logine']; if ($login == '') { unset($login);} }

if (isset($_POST['Passe'])) { $pass=$_POST['Passe']; if ($pass =='') { unset($pass);} }

 

           $login = $_POST['Logine'];

           $pass = $_POST['Passe'];

           setcookie("login", "");

               

           if (empty($login) or empty($pass))

{

           setcookie("SignError", "Вы оставили незаполненные поля.",time()+1);

           header( 'Location: /HTML/Glav.php', true, 303 );

           exit ();

}

 

$login = stripslashes($login);

$login = htmlspecialchars($login);

           $pass = stripslashes($pass);

$pass = htmlspecialchars($pass);

 

$login = trim($login);

$pass = trim($pass);

 

$result = mysql_query("SELECT ID FROM register WHERE login='$login'",$db);

           $myrow = mysql_fetch_array($result);

               

if (empty($myrow['ID'])) {

           setcookie("SignError", "Неверный логин!",time()+1);

           header( 'Location: /HTML/6strun.php', true, 303 );

exit ();

}

               

$result2 = mysql_query ("SELECT * FROM register WHERE login='$login'");

           $myrow = mysql_fetch_array($result2);

if (!empty($result2))

{

               

           if ($myrow['Pass'] == $pass) {

           header( 'Location: /HTML/Glav.php', true, 303 );

           setcookie("login", $login);

           }

           else

           {

           setcookie("SignError", "Неверный пароль!",time()+1);

           header( 'Location: /HTML/6strun.php', true, 303 );              

           }

  

}

           else {

           setcookie("SignError", "Неверный логин или пароль!",time()+1);

           header( 'Location: /HTML/6strun.php', true, 303 );              

}

           }

?>

 

Затем была создана форма для регистрации и входа пользователя.

<?php

if(!empty($_COOKIE["RegisterError"]))

{

echo "<script type=\"text/javascript\">alert('".$_COOKIE["RegisterError"]."');</script>";

}

 

if(!empty($_COOKIE["SignError"]))

{

echo "<script type=\"text/javascript\">alert('".$_COOKIE["SignError"]."');</script>";

}

?>

<html>

           <body>

                          <head>

                          <title>Muz Torg</title>

                          </head>

                          <body background="1.JPG" height="100%">

                                          <table cellpadding="10" border="1" align="center" height="100%">

                                                          <tr>

                                                                         <tr height="100">

                                                                         <td align="center" colspan="4"> <img src="internet-business-opportunity-80891.png" height="100%"></td>                                                                

                                                                         <td align="center" colspan="2" >

                                                                                         <div style="text-align:left;display:block;min-width:285px;padding:1%;width:10%;">

                                                                                         <?php

                                                                                                         if(!empty($_COOKIE["login"]))

                                                                                                         echo '<h3 >'.$_COOKIE["login"].'</h3>';

                                                                                                    else

                                                                                                         echo '<h3 >Авторизация:</h3>';

                                                                                         ?>

                                                                                         <form action="reg.php" method="POST">

                                                                                                         <input type="text" size="35" value="Логин" name="Login">

                                                                                                         <input type="text" size="35" value="Пароль" name="Pass">

                                                                                                         <input type="text" size="35" value="Email" name="Email">

                                                                                                         <input type="submit" value="Регистрация" style="padding:1px;color:#000;background:#fff;font-size:12px;">

                                                                                         </form>

                                                                                         <form action="sig.php" method="POST">

                                                                                                         <input type="text" size="35" value="Логин" name="Logine">

                                                                                                         <input type="text" size="35" value="Пароль" name="Passe">

                                                                                                         <input type="submit" value="Вход" style="padding:1px;color:#000;background:#fff;font-size:12px;">

                                                                                                         <input name="exit" type="submit" value="Выход" style="padding:1px;color:#000;background:#fff;font-size:12px;">

                                                                                         </form>

                                                                                         </div>

                                                                         </td>                                     

                                                          </tr>

                                                          <tr>

                                                                         <td width="10%">

                                                                                         <font color="white" size="6">

                                                                                         Каталог

                                                                                         <p><a href="6strun.php">1)6 cтрун</a>

                                                                                         <p><a href="7srtun.php">2)7 струн</a>

                                                                                         <p><a href="8strun.php">3)8 струн </a>

                                                                                         <p><a href="Bass.php">4)Бас</a>

                                                                                         <p><a href="acses.php">5)Аксессуары</a>

                                                                         </td>

                                                                         <td align="left" >

                                                                                         <img src="22.png" height="50%">

                                                                                         <font size="5"> Тостер Electrolux                                                                                

                                                                                         <input type="submit" value="Купить" style="padding:1px;color:#000;background:#fff;font-size:12px;">                                                                   

                                                                         </td>

                                                                         <td align="left" >

                                                                                         <img src="23.png" height="50%">

                                                                                         <font size="5"> Тостер Philips                                                           

                                                                                         <input type="submit" value="Купить" style="padding:1px;color:#000;background:#fff;font-size:12px;">                                                   

                                                                         </td>

                                                                         <td align="left" >

                                                                                         <img src="24.png" height="50%">

                                                                                         <font size="5"> Тостер Toshiba                                         

                                                                                         <input type="submit" value="Купить" style="padding:1px;color:#000;background:#fff;font-size:12px;">                                                   

                                                                         </td>

                                                                         <td align="left" >                                                 

                                                                                         <img src="25.png" height="50%">

                                                                                         <font size="5"> Тостер Electrolux                                      

                                                                                         <input type="submit" value="Купить" style="padding:1px;color:#000;background:#fff;font-size:12px;">                                                   

                                                                         </td>

                                                                         <td align="left" >

                                                                                         <img src="26.png" height="50%">

                                                                                         <font size="5"> Тостер Philips                                           

                                                                                         <input type="submit" value="Купить" style="padding:1px;color:#000;background:#fff;font-size:12px;">                                    

                                                                         </td>

                                                                                             

                                                                             

                                                                             

                                                          </tr>

                                                          <tr>

                                                                         <td colspan="6" align="center"><font size="5">Филатов Александр гр. 313</td>

                                                          </tr>

</table>

Обработка форм



Поделиться:


Последнее изменение этой страницы: 2024-06-17; просмотров: 5; Нарушение авторского права страницы; Мы поможем в написании вашей работы!

infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 3.142.251.204 (0.007 с.)