Top Banner
ΑΤΕΙ ΘΕΣΣΑΛΙΑΣ ΣΧΟΛΗ ΤΕΧΝΟΛΟΓΙΚΩΝ ΕΦΑΡΜΟΓΩΝ Τμήμα Μηχανικών Πληροφορικής ΤΕ Ανάπτυξη Ιστοσελίδας Επισκε- υής Μικροσυσκευών Π ΤΥΧΙΑΚΗ Ε ΡΓΑΣΙΑ Χαζίρογλου Κωνσταντίνος Αγαμέμνων (ΑΜ: Τ02469) Επιβλέπων: κ. Κόκκορας Φώτης ΛΑΡΙΣΑ 2015
87

Ανάπτυξη Ιστοσελίδας Καταστήματος Επισκευής Μικροσυσκευών

Nov 11, 2015

Download

Documents

kostashazir

Πτυχιακή "Ανάπτυξη Ιστοσελίδας Καταστήματος Επισκευής Μικροσυσκευών"

Χαζίρογλου Κωνσταντίνος Αγαμέμνων
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • -

    (: 02469)

    : .

    2015

  • ,

    -

    :

    , -

    .

    ,

    . , -

    .

    .

    , -

    .

    (-)

    < >

  • :

    :

    1.

    2.

    3.

  • -i-

    - .

    MySQL, . - . - , - , / .

    site - -. .

    - .

    - : HTML, CSS, PHP, MySQL, JavaScript, Ajax, Photoshop XAMPP .

  • -iii-

    -

    -

    .

    ... -

    -

    .

  • -v-

    ..................................................................................................................... I

    .............................................................................................................. III

    ............................................................................................................ V

    1 ........................................................................... 7

    1.1 HTML ................................................................................................................. 7

    1.2 CSS (CASCADING STYLES SHEETS) ................................................................. 9

    1.2.1 CSS ..................... 9

    1.2.2 ............................................... 10

    1.3 PHP ................................................................................................................. 12

    1.3.1 PHP HTML ........................................................ 12

    1.3.2 PHP .................................. 13

    1.3.3 PHP JavaScript ................................................ 13

    1.4 JAVASCRIPT ................................................................................................. 14

    1.5 AJAX (ASYNCHRONOUS JAVASCRIPT AND XML) .......................................... 16

    1.6 XML (EXTENSIBLE MARKUP LANGUAGE)........................................................ 18

    1.7 ....................................................................................................... 19

    1.7.1 .......................................................................... 19

    1.7.2 ...................................................................... 20

    1.8 MYSQL ............................................................................................................ 21

    1.9 PHPMYADMIN .................................................................................................. 22

    1.10 APACHE ......................................................................................................... 23

    1.11 .................................................................................... 23

    2 XAMPP SERVER ................................................................................................... 25

    2.1 T XAMPP ..................................................................................... 25

    2.2 XAMPP ..................................................................... 25

    2.3 .................................................................................... 28

  • -vi-

    3 SMS WEB ................................................................. 29

    3.1 SMS ...................................................................................................... 29

    3.2 SMS GATEWAY ........................................................................................... 29

    3.3 O (SMS CENTER) .......................... 30

    3.4 ................................................................................... 30

    4 ....................................................................... 31

    4.1 ........................................ 31

    4.2 FRONT END ........................................................................................... 35

    4.2.1 ............................................................................... 35

    4.2.2 ........................................................... 39

    4.2.3 ............................................................... 41

    4.2.4 ..................... 46

    4.2.5 ................................................................................... 48

    4.2.6 .................................................................................. 54

    4.2.7 .............................................................. 56

    4.3 BACK END .............................................................................................. 59

    4.3.1 .................................... 59

    4.3.2 - .................. 60

    4.3.3 ............................................... 63

    4.3.4 .......................................... 65

    4.3.5 SMS ............................................................................. 68

    4.3.6 .................................................. 71

    4.3.7 ............................................. 81

    5 ................................................................................................ 82

  • -7-

    1

    1.1 HTML

    1HTML ( )

    Hyper Text Markup Language ( )

    -

    . HTML

    , . html -

    .

    HTML

    : HTML .

    HTML

    . (browser)

    .

    html,head,body,div,span.

    : -

    .

    p,h1,h2,h3,h4,h5,h6,strong,em,address,blockquote,pre,code

  • -8-

    :

    . -

    . -

    , .

    : HTML

    , .

    .

    : - links . - - . - href, .

    : -

    .

    img, area, map, object, param.

    : html . -

    Server -

    . input,

    textarea, select, option, optiongroup, button, label, fieldset, legend

    : b, I ,tt ,sub ,sup ,big ,small

    -

    .

  • -9-

    1.2 CSS (Cascading Styles Sheets)

    2

    CSS ( )

    . -

    .

    ,

    .

    1.2.1 CSS

    css

    .

    -

    .

    browser.

    css html -

    , css

    ,

    (bandwidth). css -

    cache -

  • -10-

    server.

    css -

    . -

    css . -

    .

    css .

    ( html) -

    . -

    .

    css

    css

    , Internet Explorer Opera

    css .

    css

    .

    1.2.2

    css

    html

    css .

  • -11-

    3 css

    -

    - -

    . html

    .

    4

    html

    html

    . -

    css -

    , . -

    style

    .

    5 html

  • -12-

    1.3 PHP

    6 PHP (Hypertext Preprocessor)

    PHP (- )

    .

    PERL C. PHP

    (.. *.php). -

    PHP -

    .

    PHP (server)

    html. PHP server side.

    PHP tags

    1.3.1 PHP HTML

    PHP HTML

    PHP HTML -

    . -

    PHP .

  • -13-

    7 PHP HTML

    1.3.2 PHP

    PHP -

    (queries) SQL MySQL, Microsoft SQL Server, Oracle ..

    -

    .

    PHP MySQL.

    8 PHP MySQL

    1.3.3 PHP JavaScript

    H PHP JavaScript -

    server . -

    . -

    PHP JavaScript.

  • -14-

    9 PHP JavaScript

    AJAX

    1.4 JAVASCRIPT

    10 JavaScript

    JavaScript -

    . JavaScript

    -

    Java. Netscape Communications

    Mocha. LiveScript.

    Sun Microsystems 1995 JavaScript -

    Java -

    .

    JavaScript

    . JavaScript -

  • -15-

    (*.js). -

    .

    JavaScript ( html -

    )

    . -

    JavaScript html -

    .

    11 Javascript

    html type,

    script () JavaScript src (source)

    , .

    html .

    -

    . 11 -

    .

  • -16-

    12 JavaScript

    1.5 AJAX (Asynchronous JavaScript and XML)

    13 AJAX (Asynchronous JavaScript and XML)

    AJAX . -

    JavaScript XML

    online . AJAX -

    . online Jesse James Garrett 2005.

    -

    .

  • -17-

    -

    AJAX -

    . AJAX -

    -

    .

    AJAX

    .

    (bandwidth)

    .

    .

    . -

    URL

    .

    JavaScript

    JavaScript

    AJAX

    .

  • -18-

    1.6 XML (Extensible Markup Language)

    14XML (Extensible Markup Language)

    XML (Extensible Markup Language) -

    HTML. H XML -

    . XML Unicode.

    XML .

    15 XML

  • -19-

    1.7

    16 (Web Page)

    ( Web Page) -

    , , , .

    (Web Site). -

    , .

    1.7.1

    -

    . ,

    -

    .

    , , -

  • -20-

    . -

    (html) -

    .

    .

    1.7.2

    servers (

    PHP,ASP,JSP .. ) -

    .

    -

    , .

    .

    , navigation

    menu, .

    ,

    .

    (interactivity)

    -

    .

    . -

    -

    , ..

  • -21-

    1.8 MySQL

    MySQL

    (Relational Database Management System RDBMS ).

    .

    MySQL . -

    -

    project .

    MySQL

    (queries). -

    sql query.

    SELECT * FROM Customer

    Customer.

    PHP -

    .

    MySQL

    7

  • -22-

    1.9 PhpMyAdmin

    17 PhpMyAdmin

    phpMyAdmin PHP - MySQL Web. , , , , , , - SQL (user interface UI). phpMyAdmin PHP , - , MySQL ad-ministration () . PhpMyAdmin PHP .

    MySQL CSV SQL SQL,CSV,XML,PDF PDF

    (database schema).

  • -23-

    1.10 APACHE

    18 Apache HTTP Server

    O Apache HTTP Apache

    (web) (browser) -

    HTTP (HyperText Transfer Protocol, )

    . Apache Software Foundation

    1995 C. Apache

    Linux

    Windows, Linux, Unix Mac OS X. server

    . -

    .

    1.11

    Sams Teach Yourself HTML, CSS, and JavaScript All in One, ISBN-13: 978-0-672-33332-3

  • -24-

    http://www.webdeveloper.com/forum/showthread.php?262910-CSS-and-its-

    advantages-and-disadvantages

    http://web.archive.org/web/20120111075401/www.cpusers.gr/content.php?r=203-

    %CE%95%CE%B9%CF%83%CE%B1%CE%B3%CF%89%CE%B3%CE%AE-

    %CF%83%CF%84%CE%B1-CSS-(Tutorial)

    http://el.wikipedia.org/wiki/CSS

    http://www.w3schools.com/css/css_howto.asp

    http://www.techteam.gr/wiki/PHP#Online

    http://php.net/manual/en/intro-whatis.php

    http://el.wikipedia.org/wiki/PHP

    http://www.techteam.gr/wiki/Javascript

    http://el.wikipedia.org/wiki/JavaScript

    http://www.way2tutorial.com/ajax/ajax_advantages_disadvantages.php

    http://www.techteam.gr/wiki/AJAX

    http://el.wikipedia.org/wiki/XML

    http://el.wikipedia.org/wiki/%CE%99%CF%83%CF%84%CE%BF%CF%83%CE%B5%

    CE%BB%CE%AF%CE%B4%CE%B1

    http://www.edinteractive.co.uk/article/?id=4

    http://www.phpmyadmin.net/

    http://httpd.apache.org/ABOUT_APACHE.html

    http://www.techteam.gr/wiki/Apache

  • -25-

    2 XAMPP SERVER

    2.1 T XAMPP

    To XAMPP , -

    (open source) (cross platform).

    Apache HTTP,

    MySQL PHP PERL . -

    XAMPP. X

    Microsoft Windows, Linux,

    Solaris Mac OS

    2.2 XAMPP

    XAMPP

    1)

    .

    https://www.apachefriends.org/download.html

  • -26-

    2) , - .

  • -27-

    3) download . -

    next

    .

    4) -

    , XAMPP Control Panel -

    .

    UAC ( ). -

    UAC .

  • -28-

    5) Apache MySQL -

    .

    2.3

    http://el.wikipedia.org/wiki/XAMPP

    https://www.apachefriends.org

  • -29-

    3 SMS WEB

    -

    -

    . -

    HTTP

    .

    3.1 SMS

    SMS , -

    -

    .

    .

    . .

    .

    SMS .

    3.2 SMS GATEWAY

    SMS

    -

    .

    .

    SMSC (SMS Center)

    -

  • -30-

    . SMPP

    SMS . SMSC

    . -

    SMSC .

    -

    .

    (SMS Gateway)

    -

    SMS .

    HTTP,

    SMTP, SMPP web.

    3.3 O (SMS Center)

    SMSC

    .

    , .

    .

    ,

    .

    3.4

    http://www.developershome.com/sms/sms_tutorial.asp?page=smsIntro2

    http://en.wikipedia.org/wiki/SMS_gateway

    http://www.techopedia.com/definition/2978/sms-gateway

  • -31-

    4

    4.1

    : customer

    - -

    Null

    Customer_ID Integer, Unsigned, Au-

    to_Increment

    FirstName Varchar

    LastName Varchar

    PhoneNumber1 Varchar

    PhoneNumber1 Varchar

  • -32-

    Address Varchar

    Customer_Public_key Varchar

    : Customer_ID

    : device

    - -

    Null

    Device_ID Integer, Unsigned, Au-

    to_Increment

    Type Varchar

    Brand Varchar

    Model Varchar

    Warranty TinyInt

    DeviceInfo Varchar

    DateOfReceipt Varchar

    Customer_ID

    : Device_ID

    : repair

    - -

    Null

    Repair_ID Integer, Unsigned, Au-

    to_Increment

    State TinyInt K -

    RepairInfo Varchar

  • -33-

    Price Float

    Delivered TinyInt -

    Device_ID Varchar

    : Repair_ID

    : sparepart

    - -

    Null

    Sparepart_ID Integer, Unsigned, Au-

    to_Increment

    Code Varchar

    CompatibleProducts Varchar

    Description Text

    Availability TinyInt

    Image Varchar

    Price Float

    Category TinyInt 1

    SubCategory_ID SmallInt, Unsigned

    : Sparepart _ID

    1 (

    , , ..)

    (, , ..)

    -

    .

  • -34-

    : refferalsubcategory

    - -

    Null

    SubCategory_ID Integer, Unsigned, Au-

    to_Increment

    SubCategory Varchar

    . : -

    , ,

    ..

    SubCategoryImage Varchar

    : SubCategory _ID

    : user

    - -

    Null

    User_ID Integer, Unsigned, Au-

    to_Increment

    Username Varchar

    Password Varchar

    Salt -

    : User _ID

  • -35-

    4.2 FRONT END

    www.haziroglou.esy.es

    4.2.1

    19

    index.php

  • -36-

    -

    .H -

    . service philips, stirella, juro-pro, stiroplus, ken-

    wood, braun, rohnson, gruppe, fissler, hoover, delonghi, babylish, izzy.

  • -37-

    head.php

    navigation.php

    >

  • -38-

    sideBanner.php

    footer.php

    }

    $stmt->closeCursor();

    $conn=null;

    }

    catch(PDOException $ex)

    {

    die($ex->getMessage());

    }

    ?>

    >

    >

    >

    Copyright 2015. All Rights Reserved.

  • -39-

    4.2.2

    -

    20

    Copyright 2015. All Rights Reserved.

    : 16

    /fax: 24210 36111

  • -40-

    analosimaCatigories.php

  • -41-

    4.2.3

    -

    navigation bar.

    AJAX.

    21

    ?>

  • -42-

    analosima.php

    var rpp = ; // results per page

    var last = ; // last page number

    var category = "";

    request_page(1);

  • -43-

    pagination.js

    function request_page(pn){

    var ListViewInner = document.getElementById("ListViewInner");

    var pagination_controls = document.getElementById("pagination_controls");

    var xmlhttp;

    if (window.XMLHttpRequest)

    xmlhttp = new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari

    else if (window.ActiveXObject)

    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5

    else

    alert("Your browser does not support XMLHTTP!");

    ListViewInner.innerHTML = "";

    xmlhttp.open("POST", "Connections/pgnParser.php", true);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    xmlhttp.onreadystatechange = function() {

    if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {

    var dataArray = xmlhttp.responseText.split("|.|");

    var html_output = "";

    for(i = 0; i < dataArray.length - 1; i++){

    var itemArray = dataArray[i].split("|");

    var available='';

    if(itemArray[4] == "1")

    available = 'images/Available.png';

    else

    available = 'images/Unavailable.png';

    html_output += ''+ itemArray[1] +' : '+ itemArray[2]+'';

    }

    ListViewInner.innerHTML = html_output;

    }

    }

    xmlhttp.send("rpp="+rpp+"&last="+last+"&pn="+pn+"&category="+category);

    var paginationCtrls = "";

    if(last != 1){

    if (pn > 1) {

    paginationCtrls += '';

    }

    if(pn < 4)

    {

    for(i=1;i

  • -44-

    pgnConnection.php

    else

    {

    paginationCtrls += ''+ i +'';

    }

    }

    }

    else

    {

    for(i=pn-2;i

  • -45-

    pgnParser.php

    $last = ceil($record['total_rows']/$rpp);

    // This makes sure $last cannot be less than 1

    if($last < 1)

    $last = 1;

    $stmt->closeCursor();

    $conn = null;

    }

    catch(PDOException $ex)

    {

    die(" - ");

    }

    ?>

  • -46-

    4.2.4

    .

    $description = $result['Description'];

    $availability = $result['Availability'];

    $image = $result['Image'];

    $dataString .= $code

    .'|'.$name.'|'.$compatibleProducts.'|'.$description.'|'.$availability.'|'.$image.'|.|';

    }

    $stmt->closeCursor();

    $conn = null;

    echo $dataString;

    }

    catch(PDOException $ex)

    {

    echo $ex->getMessage();

    }

    }

    else

    {

    echo " - ";

    }

    ?>

  • -47-

    productDetails.php

  • -48-

    4.2.5

    . -

    .

  • -49-

    22

    contact.php

  • -50-

    16, , 38333

    24210 36111

    [email protected]

    ,

    8:30 - 15:00

    , ,

    8:30 - 19:30

    9:00 - 14:00

    Email

  • -51-

    Ajax

    .

    javascript php

    .

    contact-functions.js

    function send()

    {

    if(validate())

    {

    var name = document.getElementById("name").value;

    var email = document.getElementById("email").value;

    var subject = document.getElementById("subject").value;

    var message = document.getElementById("message").value;

    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("POST","Connections/sendEmail.php",true);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    xmlhttp.onreadystatechange = function() {

    if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {

    var response = xmlhttp.responseText;

  • -52-

    document.getElementById("result").innerHTML = response;

    }

    }

    xmlhttp.send("name=" + name + "&email=" + email + "&subject=" + subject + "&message="

    + message);

    }

    }

    function validate()

    {

    // set empty error messages

    document.getElementById("err_name").innerHTML = "";

    document.getElementById("err_email").innerHTML = "";

    document.getElementById("err_message").innerHTML = "";

    document.getElementById("result").innerHTML = "";

    var flag = true;

    flag = validateEmail();

    if(isEmpty("name"))

    flag = false;

    if(isEmpty("message"))

    flag = false;

    if(flag)

    {

    return true;

    }

    return false;

    }

    function isEmpty(id)

    {

    value = document.getElementById(id).value;

    if(!value.trim())

    {

    document.getElementById("err_" + id).innerHTML = " .";

    return true;

    }

    return false;

    }

    function validateEmail()

    {

    var mail = document.getElementById("email").value;

    var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

    if(!mail.trim())

    {

    document.getElementById("err_email").innerHTML = " .";

    return false;

    }

    if(mail.match(mailformat))

    {

    return true;

    }

    document.getElementById("err_email").innerHTML = " email.";

    return false;

    }

  • -53-

    sendEmail.php

  • -54-

    4.2.6

    .

    23

    function clean($value)

    {

    $value = trim($value);

    $value = stripslashes($value);

    $value = htmlspecialchars($value);

    return $value;

    }

    ?>

  • -55-

    location.php

    function initialize() {

    var map = document.getElementById('map');

    var myLatlng = new google.maps.LatLng(39.36692, 22.93888);

    var mapOptions = {

    center: myLatlng,

    zoom: 14,

    mapTypeId: google.maps.MapTypeId.ROADMAP

    }

    var map = new google.maps.Map(map, mapOptions)

    var contentString = '

    16, , 38333/fax: 24210

    [email protected]';

    var infowindow = new google.maps.InfoWindow({

    content: contentString

    });

    var marker = new google.maps.Marker({

    position: myLatlng,

    map: map,

    title: 'Click me!'

    });

    google.maps.event.addListener(marker, 'click', function() {

    infowindow.open(map,marker);

    });

    }

    google.maps.event.addDomListener(window, 'load', initialize);

  • -56-

    4.2.7

    -

    .

    24

    repair.php

  • -57-

    getResult.php

  • -58-

    try

    {

    $conn = new

    PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND =>

    "SET NAMES utf8"));

    $sql_query = "SELECT Type, Brand, Model, State FROM customer, device, repair WHERE cus-

    tomer.Customer_Public_Key =:value AND customer.Customer_ID = device.Customer_ID AND de-

    vice.Device_ID = repair.Device_ID";

    $stmt = $conn->prepare($sql_query);

    $stmt->bindParam(':value', $value);

    $stmt->execute();

    $dataString ='';

    while($result = $stmt -> fetch())

    {

    $type = $result['Type'];

    $brand = $result['Brand'];

    $model = $result['Model'];

    $state = checkState($result['State']);

    $dataString .= $type .'|'.$brand.'|'.$model.'|'.$state.'|.|';

    }

    $stmt->closeCursor();

    $conn=null;

    echo $dataString;

    }

    catch(PDOException $ex)

    {

    $dataString = "error" .'|' ." .";

    echo $dataString;

    }

    }

    function clean($value)

    {

    $value = trim($value);

    $value = stripslashes($value);

    $value = htmlspecialchars($value);

    $value = mb_strtoupper($value,'UTF-8');

    return $value;

    }

    function checkState($state)

    {

    switch($state)

    {

    case 1:

    return " ";

    break;

    case 2:

    return " ";

    break;

  • -59-

    4.3 BACK END

    4.3.1

    .

    url .

    http://www.haziroglou.esy.es/login_admin.php

    25

    case 3:

    return "";

    break;

    case 4:

    return "";

    break;

    case 5:

    return "";

    break;

    }

    }

    ?>

  • -60-

    4.3.2 -

    , -

    .

    26

    -

    . ,

    ( ) .

    -

    -

    .

    AJAX.

  • -61-

    pagination_conn.php

  • -62-

    pagination_parser.php

  • -63-

    4.3.3

    -

    .

    AJAX.

    27

    JavaScript Server

    else

    {

    echo " - ";

    }

    ?>

    function validateForm()

    {

    var code = document.getElementById("code").value;

    var category = document.getElementById("category").value;

    var subCategory = document.getElementById("subCategory").value;

    var spName = document.getElementById("spName").value;

  • -64-

    var spPrice = document.getElementById("spPrice").value;

    var description = document.getElementById("description").value;

    var availability = document.getElementById("availability").value;

    var imgFile = document.getElementById("imgFile");

    var subCategImageFile = document.getElementById("subCategImageFile");

    var imgOutput = document.getElementById("imgOutput");

    var compatibleProducts = document.getElementById("compatibleProducts").value;

    if(validate("code") && validate("category") && validate("subCategory") && vali-

    date("spName") && validate("spPrice"))

    {

    var data = new FormData();

    if(imgFile.files.length == 0)

    {

    var c = confirm(" .\n ?");

    if(!c)

    return false;

    }

    else

    if(imgOutput.naturalHeigth != 120 && imgOutput.naturalWidth != 120)

    {

    alert(" 120x120 px\n -

    ...");

    return false;

    }

    else

    data.append("imgFile",imgFile.files[0]);

    if(category == 1 && subCategory == '|new-Sub-Category|')

    {

    var new_subCategory = document.getElementById("new_subCategory").value;

    data.append("new_subCategory",new_subCategory);

    if(subCategImageFile.files.length != 0)

    {

    data.append('subCategImageFile',subCategImageFile.files[0]);

    }

    }

    data.append("code",code);

    data.append("category",category);

    data.append("subCategory",subCategory);

    data.append("spName",spName);

    data.append("availability",availability);

    data.append("spPrice",spPrice);

    data.append("description",description);

    data.append("compatibleProducts",compatibleProducts);

    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("POST","insert_sparepart_conn.php",true);

    //xmlhttp.setRequestHeader("Content-type", "multipart/form-data");

    xmlhttp.onreadystatechange = function()

    {

    if(xmlhttp.readyState == 4 && xmlhttp.status == 200)

    {

    var response = xmlhttp.responseText;

    alert(response);

    //location.reload();

    }

    }

    xmlhttp.send(data);

    }

    }

  • -65-

    4.3.4

    .

    28 -

    -

    .

    query

    .

    var response = xmlhttp.responseText;

    alert(response);

    //location.reload();

    }

    }

    xmlhttp.send(data);

    }

    }

  • -66-

    if (isset($_POST['customerID'], $_POST['lastname'], $_POST['type'], $_POST['brand'],

    $_POST['warranty'], $_POST['phoneNumber'], $_POST['startDate'], $_POST['endDate']) )

    {

    $id = clean($_POST['customerID']);

    $lastname = clean($_POST['lastname']);

    $type = clean($_POST['type']);

    $brand = clean($_POST['brand']);

    $warranty = clean($_POST['warranty']);

    $phoneNumber = clean($_POST['phoneNumber']);

    $startDate = clean($_POST['startDate']);

    $endDate = clean($_POST['endDate']);

    $where_query = "customer.Customer_ID = device.Customer_ID AND ";

    $counter = 0;

    $data = array(

    "customer.Customer_Public_Key" => $id,

    "LastName" => $lastname,

    "Type" => $type,

    "Brand" => $brand,

    "Warranty" => $warranty,

    "PhoneNumber1" => $phoneNumber,

    "DateOfReceipt" => $startDate,

    "DateOfReceipt_EndDate" => $endDate

    );

    foreach($data as $key => $value)

    {

    if($value !="")

    {

    if($counter > 0)

    $where_query .= " AND ";

    if($key == "DateOfReceipt")

    {

    if($data['DateOfReceipt_EndDate'] != "")

    {

    $where_query .= "DateOfReceipt BETWEEN '" . $value . " 00:00:00' AND '" .

    $endDate . " 23:59:59 '";

    $counter++;

    break;// loop query

    }

    else

    {

    $where_query .= $key . " LIKE " . "'" . $value . "%'";

    $counter++;

    }

    }

    else

    {

    $where_query .= $key . " = " . "'" . $value . "'";

    $counter++;

    }

    }

    }

    if($counter == 0)

    {

    echo " alert(' ') ";

    exit;

    }

  • -67-

    -

    .

    29

    30

    -

    .

  • -68-

    31

    32

    4.3.5 SMS

    , -

    .

    SMS

    Clickatell HTTP .

  • -69-

  • -70-

    Clickatell

    , HTTP, -

    .

    utf8_to_unicode(text)

    utf8 Unicode. -

    utf8. utf8

    ( ) Unicode. -

    -

    160 70. .

    else

    {

    $dataString = "error" .'|'. " !";

    echo $dataString;

    }

    }

    else

    {

    echo "Authentication failure: ". $ret[0];

    }

    }

    else

    {

    $dataString = "error" .'|'. " - ";

    echo $dataString;

    }

    function utf8_to_unicode($str) {

    $unicode = array();

    $values = array();

    $lookingFor = 1;

    for ($i = 0; $i < strlen($str); $i++) {

    $thisValue = ord($str[$i]);

    if ($thisValue < 128)

    $unicode[] = str_pad(dechex($thisValue), 4, "0", STR_PAD_LEFT);

    else {

    if (count($values) == 0) $lookingFor = ($thisValue < 224) ? 2 : 3;

    $values[] = $thisValue;

    if (count($values) == $lookingFor) {

    $number = ($lookingFor == 3) ?

  • -71-

    4.3.6

    .

    33

    -

    . Server

    AJAX.

    (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64):

    (($values[0] % 32) * 64) + ($values[1] % 64);

    $number = strtoupper(dechex($number));

    $unicode[] = str_pad($number, 4, "0", STR_PAD_LEFT);

    $values = array();

    $lookingFor = 1;

    }

    }

    }

    return ($unicode);

    }

    ?>

  • -72-

    search_spearpart.php

    var rpp = 5; // results per page

    var last; // last page number global

    function request_page(pn){

    var code = document.getElementById("code").value;

    var category = document.getElementById("category").value;

    var subCategory = document.getElementById("subCategory").value;

    var spName = document.getElementById("spName").value;

    var availability = document.getElementById("availability").value;

    if(code =='' && category =='' && subCategory =='' && spName =='' && availability =='')

    alert(" !");

    else

    {

    if(pn == 1)

    {

    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("POST","pagn_search_sparepart_conn.php",false);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    xmlhttp.send("code="+code + "&category="+ category+"&subCategory="+ subCategory+

    "&spName="+spName

    +"&availability="+availability);

    var response = xmlhttp.responseText;

    last = parseInt(response);

    if(isNaN(last))

    {

    alert(response);

    return false;

    }

    }

    var tableRowNum = 0;

    var results = document.getElementById("results");

    var pagination_controls = document.getElementById("pagination_controls");

    var hr = new XMLHttpRequest();

    hr.open("POST", "pagn_search_sparepart_parser.php", true);

    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    hr.onreadystatechange = function() {

    if(hr.readyState == 4 && hr.status == 200) {

    dataArray = hr.responseText.split("|.|");

    var html_output = "";

  • -73-

    for(i = 0; i < dataArray.length - 1; i++){

    var itemArray = dataArray[i].split("|");

    html_output += ""

    + "" +'';

    }

    paginationCtrls += ''+pn+'';

    if (pn != last) {

    paginationCtrls += '';

    }

    }

    pagination_controls.innerHTML = paginationCtrls;

    }

    }

    function updateSpare(rowNumber)

    {

    var cellValue = document.getElementById("results").rows[rowNumber].cells;

    var code = cellValue[1].innerHTML;

    var url = "../updateSparepart/updateSparepart.php?code=" + code;

    window.open(url, "_blank", "fullscreen = yes");

    }

  • -74-

    -

    H

    H

  • -75-

    1

  • -76-

    pagn_search_sparepart_conn.php

  • -77-

    pagn_search_sparepart_parser.php

    try

    {

    $conn = new

    PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND =>

    "SET NAMES utf8"));

    // This first query is just to get the total count of rows

    $sql_query = ("SELECT COUNT(sparepart.Sparepart_ID) AS total_rows FROM sparepart,

    refferalsubcategory WHERE $where_query");

    $stmt = $conn -> query($sql_query);

    $record = $stmt -> fetch(PDO::FETCH_ASSOC);

    // Specify how many results per page

    $rpp = 5;

    // This tells us the page number of our last page

    $last = ceil($record['total_rows']/$rpp);

    // This makes sure $last cannot be less than 1

    if($last < 1){

    $last = 1;

    }

    // Close the database connection

    $stmt->closeCursor();

    $conn = null;

    echo $last;

    }

    catch(PDOException $ex)

    {

    die($ex -> getMessage());

    }

    }

    else

    {

    echo " - ";

    }

    ?>

  • -78-

    try

    {

    $conn = new

    PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND =>

    "SET NAMES utf8"));

    // This sets the range of rows to query for the chosen $pn

    $limit = 'LIMIT ' .($pn - 1) * $rpp .',' .$rpp;

    applying $limit

    $sql_query = "SELECT Image, Code, Category, refferalsubcategory.SubCategory, Name, Price,

    Availability FROM sparepart, refferalsubcategory WHERE ";

    session_start();

    $sql_query .= $_SESSION['where_query'] . " $limit";

    $stmt = $conn -> query($sql_query);

    $dataString = '';

    while($result = $stmt -> fetch())

    {

    $image = $result['Image'];

    $code = $result['Code'];

    $category = $result['Category'];

    $subCategory = $result['SubCategory'];

    $spName = $result['Name'];

    $price = $result['Price'].' ';

    if($result['Availability'] == 0)

    $availability = "";

    else

    $availability = "";

    if($result['Category'] == 0)

    $category = "";

    else

    $category = "";

    $dataString .= $image .'|'. $code .'|'. $category.'|'. $subCategory. '|'. $spName.'|'.

    $availability.'|'.$price.'|.|';

    }

    $stmt->closeCursor();

    $conn = null;

    echo $dataString;

    }

    catch(PDOException $ex)

    {

    die($ex -> getMessage());

    }

    }

    else

    {

    echo " - ";

    }

    ?>

  • -79-

    -

    , , -

    .

    34

    35

  • -80-

  • -81-

    4.3.7

    (logout)

    (username)

    36

    logout.php

  • -82-

    5

    -

    .

    .

    -

    .

    ,

    .

    -

    PHP JavaScript.

  • -83-

    [1] Sams Teach Yourself HTML, CSS, and JavaScript All in One, ISBN-13: 978-0-

    672-33332-3

    [2] PHP, MySQL, Apache , ISBN: 978-

    960512-655-1

    [3] http://www.webdeveloper.com Forum

    [4] http://web.archive.org

    [5] http://el.wikipedia.org .

    [6] http://www.w3schools.com

    [7] http://www.techteam.gr

    [8] http://php.net site php

    [9] http://www.way2tutorial.com

    [10] http://www.edinteractive.co.uk/article/?id=4

    [11] http://www.phpmyadmin.net site phpmyadmin

    [12] http://httpd.apache.org site Apache HTTP Server

    [13] https://www.apachefriends.org Apache

    [14] http://www.developershome.com

    [15] http://www.techopedia.com