Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Diplommm.docx
Скачиваний:
35
Добавлен:
25.02.2016
Размер:
405.92 Кб
Скачать

3.3 Php scripts

In application php scripts are used for processing information with JSON for storing dates in the database. All the scripts are used to connect to database. In Table 7 written detailed description of php scripts. In figure 10 written example of one php script.

Table 7 - Description of php scripts

Name

description

Save.php

Processes data and stores the contacts database

Sav.php

Clears the database from old contacts

Login.php

Checks the data for authorization

Backup.php

Copies the information from the database and sends to the application to save to phone

Register.php

Enters to the database of the new member

DB_connect.php

Creates a database connection

DB_config.php

Database Settings

<?php

$response = array();

// check for required fields

if (isset($_POST['login']) && isset($_POST['password'])) {

$login = $_POST['login'];

$password = $_POST['password'];

// include db connect class

require_once __DIR__ . '/db_connect.php';

// connecting to db

$db = new DB_CONNECT();

$men = mysql_query("SELECT * FROM users where login = '$login'");

if(mysql_num_rows($men) > 0){

$response["success"] = 2;

$response["message"] = "login zanyat.";

// echoing JSON response

echo json_encode($response);

}else{

// mysql inserting a new row

$result = mysql_query("INSERT INTO users(login, password) VALUES('$login', '$password')");

// check if row inserted or not

if ($result) {

// successfully inserted into database

$response["login"] = $login;

$response["success"] = 1;

$response["message"] = "Product successfully created.";

// echoing JSON response

echo json_encode($response);

} else {

// failed to insert row

$response["success"] = 0;

$response["message"] = "Oops! An error occurred.";

// echoing JSON response

echo json_encode($response);

}

}

}

?>

Figure 10 - Register.php

3.4 Xml files

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. In diploma project xml used for designing application. XML is view of application for user. In table 8 xml’s used in diploma project. In figure 11 example of xml file.

Table 8 - XML descriptions.

Name

description

activity_main.xml

For designing main page

backup.xml

For designing backup page

call.xml

For designing call page

login.xml

For designing login page

register.xml

For designing register page

simple.xml

For creating list

success.xml

For designing logged in page

styles.xml

Design colors and font

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

>

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Login"

android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="login" />

<EditText

android:id="@+id/eLogin"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10" >

<requestFocus />

</EditText>

<TextView

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="password" />

<EditText

android:id="@+id/ePass"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:inputType="textPassword" />

<TextView

android:id="@+id/eError"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

<Button

android:id="@+id/bLogin"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Login" />

</LinearLayout>

Figure 11 - Login.XML

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]