0% found this document useful (0 votes)
80 views5 pages

Ujian Tengah Semester Pemrograman Mobile 3

The document is an exam submission from Akhmad Fauzi, student ID 11118006, studying Information Systems. It includes screenshots of an Android login activity layout, SQL code to create a login table and insert sample data, and PHP code for a connection file, login query, and response.

Uploaded by

AkhFauzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views5 pages

Ujian Tengah Semester Pemrograman Mobile 3

The document is an exam submission from Akhmad Fauzi, student ID 11118006, studying Information Systems. It includes screenshots of an Android login activity layout, SQL code to create a login table and insert sample data, and PHP code for a connection file, login query, and response.

Uploaded by

AkhFauzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Nama : Akhmad Fauzi

NIM : 11118006
Jurusan : Sistem Informasi
Mata Kuliah : Pemrograman Mobile 3

Ujian Tengah Semester Pemrograman


Mobile 3

1. Screenshoot Hasil

a) activity_main.xml
1. <?xml version="1.0" encoding="utf-8"?>
2. <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
3. xmlns:app="http://schemas.android.com/apk/res-auto"
4. xmlns:tools="http://schemas.android.com/tools"
5. android:layout_width="match_parent"
6. android:layout_height="match_parent"
7. android:padding="16dp"
8. tools:context=".MainActivity">
9.
10. <TextView
11. android:id="@+id/txtFrmLogin"
12. android:layout_width="wrap_content"
13. android:layout_height="wrap_content"
14. android:layout_centerHorizontal="true"
15. android:layout_marginTop="16dp"
16. android:text="Login Form"
17. android:textSize="38sp"
18. android:textStyle="bold" />
19.
20. <ImageView
21. android:id="@+id/logo"
22. android:layout_width="250dp"
23. android:layout_height="80dp"
24. android:layout_below="@id/txtFrmLogin"
25. android:layout_centerHorizontal="true"
26. app:srcCompat="@drawable/logo " />27.
28. <EditText
29. android:id="@+id/edtUsername"
30. android:layout_width="match_parent"
31. android:layout_height="wrap_content"
32. android:layout_below="@id/logo"
33. android:layout_marginTop="28dp"
34. android:hint="Enter Username"
35. android:inputType="text"
36. android:minHeight="48dp"
37. android:textSize="24sp" />
38.
39. <EditText
40. android:id="@+id/edtPassword"
41. android:layout_width="match_parent"
42. android:layout_height="wrap_content"
43. android:layout_below="@id/edtUsername"
44. android:layout_marginTop="16dp"
45. android:hint="Enter Password"
46. android:inputType="textPassword"
47. android:minHeight="48dp"
48. android:textSize="24sp" />
49.
50. <Button
51. android:id="@+id/btnLogin"
52. android:layout_width="120dp"
53. android:layout_height="wrap_content"
54. android:layout_below="@id/edtPassword"
55. android:layout_centerHorizontal="true"
56. android:layout_marginTop="8dp"
57. android:text="LOGIN"
58. android:textSize="18sp" />
59.
60. <Button
61. android:id="@+id/btnCancel"
62. android:layout_width="120dp"
63. android:layout_height="wrap_content"
64. android:layout_below="@id/btnLogin"
65. android:layout_centerHorizontal="true"
66. android:text="CANCEL"
67. android:textSize="18sp" />
68. </RelativeLayout>
2. Web Service Menggunakan PHP dan MySQL
a) SQL
1. CREATE TABLE `form_login` (
2. `id` INT(11) NOT NULL,
3. `username` VARCHAR(100) NOT NULL,
4. `password` VARCHAR(100) NOT NULL
5. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6.
7. --
8. -- Dumping data for table `form_login `
9. --
10.
11. INSERT INTO `tabel_form_login` (`id`,
`username`,
12.`password`) VALUES 'admin'),
(1, 'admin',
13. (2, 'user', 'user');
14.
15. --
16. -- Indexes for dumped tables
17. --
18.
19. --
20. -- Indexes for table `form login`
21. --
22. ALTER TABLE `form_login`
23. ADD PRIMARY KEY (`id`);
24.
25. --
26. -- AUTO_INCREMENT for dumped tables
27. --
28.
29. --
30. -- AUTO_INCREMENT for table `form_login`
31. --
32. ALTER TABLE `form_login`
33. MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=3;
34. COMMIT;

b) koneksi.php
1. <?php
2.
3. $koneksi = mysqli_connect("localhost", "root", "root",
"UTS_Mobile");4.
5.
6. if (mysqli_connect_error()) {
7. echo "Koneksi Anda Tidak Berhasil : " . mysqli_connect_error();
8. }
9.
c) login.php
1. <?php
2.
3. include "koneksi.php";
4.
5. $username = $_GET['username'];
6. $password =
$_GET['password'];7.
8. $query = "SELECT *
9. FROM form_login
10. WHERE username = '" . $username . "'
11. AND password = '" . $password .
"'";12.
13. $result = mysqli_query($koneksi, $query);
14. if (mysqli_num_rows($result) > 0) {
15. $response = [];
16. $code = "login_true";
17. $message = "Anda Login Sebagai " . $username;
18. array_push($response, ["code" => $code, "message" =>
$message]);
19.  echo json_encode(["server_response" => $response]);
20. } else {
21. $response = [];
22. $code = "login_false";
23. $message = "Username atau Password Salah…";
24. array_push($response, ["code" => $code, "message" =>
$message]);
25. echo json_encode(["server_response" => $response]);
26. }
27.
28. mysqli_close($koneksi);

You might also like