<?php
require_once "../lib/nusoap.php";
$server = new soap_server();
$server->configureWSDL("Mahasiswa UII","urn:akademik");
if(!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
//function_view_all_data
function dataMahasiswa($data){
$conn = mysqli_connect("localhost","root","","ws");
$results = $conn->query("SELECT nim, nama, alamat FROM mahasiswa");
$ArrayHasil = [];
while ($result = mysqli_fetch_array($results,MYSQLI_ASSOC)) {
$ArrayHasil[] = $result ;
}
return json_encode($ArrayHasil);
}
//function_search_data
function cariMahasiswa($id){
$conn = mysqli_connect("localhost","root","","ws");
$results = $conn->query("SELECT nim, nama, alamat FROM mahasiswa WHERE nim ='$id' ");
$ArrayHasil = [];
while ($result = mysqli_fetch_array($results,MYSQLI_ASSOC)) {
$ArrayHasil[] = $result ;
}
return json_encode($ArrayHasil);
}
//function_input_data
function insertMahasiswa($nim,$nama,$alamat){
$conn = mysqli_connect("localhost","root","","ws");
$nim_input = $nim;
$nama_input = $nama;
$alamat_input = $alamat;
$sql = "REPLACE INTO `mahasiswa` (`nim`, `nama`, `alamat`) VALUES ('$nim', '$nama', '$alamat')";
if($results=mysqli_query($conn, $sql)){
return "Employee inserted";
}else{
return "data not inserted";
}
}
//function_update_data
function updateMahasiswa($nim,$nama,$alamat){
$conn = mysqli_connect("localhost","root","","ws");
$nim_input = $nim;
$nama_input = $nama;
$alamat_input = $alamat;
$sql = "UPDATE `mahasiswa` set `nama`='$nama', `alamat`='$alamat' WHERE `nim` = '$nim'";
if($results=mysqli_query($conn, $sql)){
return "Employee inserted";
}else{
return "data not inserted";
}
}
//registrasi fungsi ke server
$server->register("dataMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#insertMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("cariMahasiswa",array("id"=>"xsd:int"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#cariMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("insertMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#insertMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("updateMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#updateMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->service($HTTP_RAW_POST_DATA);
===
<?php
require_once "../lib/nusoap.php";
$client = new nusoap_client("http://localhost/051001/mysqli/ws.php?wsdl");
?>
<form id='form_cari' method="POST">
Cari Nomor Mahasiswa :</br><input id='cari_nim' name='nim_cari' required />
<input type='submit' id='submit_cari' value='Cari'/>
</form>
</br>
<form id='form_input' method="POST">
<table>
<tr><td>Nomor Mahasiswa :<td><input id='input_nim' name='nim' required /></tr>
<tr><td>Nama Mahasiswa :<td><input name='nama' required /></tr>
<tr><td>Alamat Asal :<td><input name='alamat' required /></tr>
<tr>
<td><input type='submit' value='Simpan'/></td>
</tr>
</table>
</form>
<form id='form_data' method="POST">
<input type='hidden' id='data' name='data' />
<input type='submit' value='View Data'/>
</form>
<?php
//input
if(isset($_POST['nim']) and isset ($_POST['nama']) and isset ($_POST['alamat']) ){
$conn = mysqli_connect("localhost","root","","ws");
$nim = mysqli_real_escape_string($conn, $_POST['nim']);
$nama = mysqli_real_escape_string($conn, $_POST['nama']);
$alamat = mysqli_real_escape_string($conn, $_POST['alamat']);
//bisa and isset */
$mahasiswa_1 = $client->call("insertMahasiswa",array("nim"=>"$nim","nama"=>"$nama","alamat"=>"$alamat"));
}
?>
<?php
//cari
if(isset($_POST['nim_cari'])) {
$nim_cari = $_POST['nim_cari'];
$mahasiswa_1 = $client->call("cariMahasiswa",array("id"=>"$nim_cari"));
$mahasiswa_1 = json_decode($mahasiswa_1);
foreach ($mahasiswa_1 as $mhs) {
/* echo "<td>".$mhs->nim."</td>
<td> ".$mhs->nama."</td>
<td>".$mhs->alamat." "."</td>";
} */
echo "<form id='form_edit' method='POST'>
<table>
<tr><td>Nomor Mahasiswa :<td><input value='".$mhs->nim."' name='update_nim'/></tr>
<tr><td>Nama Mahasiswa :<td><input value='".$mhs->nama."' name='update_nama'/></tr>
<tr><td>Alamat Asal :<td><input value='".$mhs->alamat."' name='update_alamat'/></tr>
<tr>
<td><input type='submit' value='Update'/></td>
</tr>
</table>
</form>";
}
}
?>
<?php
//view_data
if(isset($_POST['data'])) {
$data = $_POST['data'];
$mahasiswa_1 = $client->call("dataMahasiswa",array("data"=>"071002239"));
$mahasiswa_1 = json_decode($mahasiswa_1);
echo "<table border='1' width='100%'><tr><th>Nomor Induk Mahasiswa</th><th>Nama Mahasiswa</th><th>Alamat</th></tr>";
foreach ($mahasiswa_1 as $mhs) {
echo "<tr>";
echo "<td>".$mhs->nim."</td>
<td> ".$mhs->nama."</td>
<td>".$mhs->alamat." "."</td>";
echo "</tr>";
}
echo "</table>";
}
//update
if(isset($_POST['update_nim']) and isset ($_POST['update_nama']) and isset ($_POST['update_alamat']) ){
$conn = mysqli_connect("localhost","root","","ws");
$nim = mysqli_real_escape_string($conn, $_POST['update_nim']);
$nama = mysqli_real_escape_string($conn, $_POST['update_nama']);
$alamat = mysqli_real_escape_string($conn, $_POST['update_alamat']);
//bisa and isset */
$mahasiswa_1 = $client->call("updateMahasiswa",array("nim"=>"$nim","nama"=>"$nama","alamat"=>"$alamat"));
}
?>
require_once "../lib/nusoap.php";
$server = new soap_server();
$server->configureWSDL("Mahasiswa UII","urn:akademik");
if(!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
//function_view_all_data
function dataMahasiswa($data){
$conn = mysqli_connect("localhost","root","","ws");
$results = $conn->query("SELECT nim, nama, alamat FROM mahasiswa");
$ArrayHasil = [];
while ($result = mysqli_fetch_array($results,MYSQLI_ASSOC)) {
$ArrayHasil[] = $result ;
}
return json_encode($ArrayHasil);
}
//function_search_data
function cariMahasiswa($id){
$conn = mysqli_connect("localhost","root","","ws");
$results = $conn->query("SELECT nim, nama, alamat FROM mahasiswa WHERE nim ='$id' ");
$ArrayHasil = [];
while ($result = mysqli_fetch_array($results,MYSQLI_ASSOC)) {
$ArrayHasil[] = $result ;
}
return json_encode($ArrayHasil);
}
//function_input_data
function insertMahasiswa($nim,$nama,$alamat){
$conn = mysqli_connect("localhost","root","","ws");
$nim_input = $nim;
$nama_input = $nama;
$alamat_input = $alamat;
$sql = "REPLACE INTO `mahasiswa` (`nim`, `nama`, `alamat`) VALUES ('$nim', '$nama', '$alamat')";
if($results=mysqli_query($conn, $sql)){
return "Employee inserted";
}else{
return "data not inserted";
}
}
//function_update_data
function updateMahasiswa($nim,$nama,$alamat){
$conn = mysqli_connect("localhost","root","","ws");
$nim_input = $nim;
$nama_input = $nama;
$alamat_input = $alamat;
$sql = "UPDATE `mahasiswa` set `nama`='$nama', `alamat`='$alamat' WHERE `nim` = '$nim'";
if($results=mysqli_query($conn, $sql)){
return "Employee inserted";
}else{
return "data not inserted";
}
}
//registrasi fungsi ke server
$server->register("dataMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#insertMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("cariMahasiswa",array("id"=>"xsd:int"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#cariMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("insertMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#insertMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->register("updateMahasiswa",
array("nim"=>"xsd:string", "nama"=>"xsd:string", "alamat"=>"xsd:string"),
array("return"=>"xsd:string"),
"urn:akademik",
"urn:akademik#updateMahasiswa",
"rpc",
"encoded",
"Carga todos los vehículos"
);
$server->service($HTTP_RAW_POST_DATA);
===
<?php
require_once "../lib/nusoap.php";
$client = new nusoap_client("http://localhost/051001/mysqli/ws.php?wsdl");
?>
<form id='form_cari' method="POST">
Cari Nomor Mahasiswa :</br><input id='cari_nim' name='nim_cari' required />
<input type='submit' id='submit_cari' value='Cari'/>
</form>
</br>
<form id='form_input' method="POST">
<table>
<tr><td>Nomor Mahasiswa :<td><input id='input_nim' name='nim' required /></tr>
<tr><td>Nama Mahasiswa :<td><input name='nama' required /></tr>
<tr><td>Alamat Asal :<td><input name='alamat' required /></tr>
<tr>
<td><input type='submit' value='Simpan'/></td>
</tr>
</table>
</form>
<form id='form_data' method="POST">
<input type='hidden' id='data' name='data' />
<input type='submit' value='View Data'/>
</form>
<?php
//input
if(isset($_POST['nim']) and isset ($_POST['nama']) and isset ($_POST['alamat']) ){
$conn = mysqli_connect("localhost","root","","ws");
$nim = mysqli_real_escape_string($conn, $_POST['nim']);
$nama = mysqli_real_escape_string($conn, $_POST['nama']);
$alamat = mysqli_real_escape_string($conn, $_POST['alamat']);
//bisa and isset */
$mahasiswa_1 = $client->call("insertMahasiswa",array("nim"=>"$nim","nama"=>"$nama","alamat"=>"$alamat"));
}
?>
<?php
//cari
if(isset($_POST['nim_cari'])) {
$nim_cari = $_POST['nim_cari'];
$mahasiswa_1 = $client->call("cariMahasiswa",array("id"=>"$nim_cari"));
$mahasiswa_1 = json_decode($mahasiswa_1);
foreach ($mahasiswa_1 as $mhs) {
/* echo "<td>".$mhs->nim."</td>
<td> ".$mhs->nama."</td>
<td>".$mhs->alamat." "."</td>";
} */
echo "<form id='form_edit' method='POST'>
<table>
<tr><td>Nomor Mahasiswa :<td><input value='".$mhs->nim."' name='update_nim'/></tr>
<tr><td>Nama Mahasiswa :<td><input value='".$mhs->nama."' name='update_nama'/></tr>
<tr><td>Alamat Asal :<td><input value='".$mhs->alamat."' name='update_alamat'/></tr>
<tr>
<td><input type='submit' value='Update'/></td>
</tr>
</table>
</form>";
}
}
?>
<?php
//view_data
if(isset($_POST['data'])) {
$data = $_POST['data'];
$mahasiswa_1 = $client->call("dataMahasiswa",array("data"=>"071002239"));
$mahasiswa_1 = json_decode($mahasiswa_1);
echo "<table border='1' width='100%'><tr><th>Nomor Induk Mahasiswa</th><th>Nama Mahasiswa</th><th>Alamat</th></tr>";
foreach ($mahasiswa_1 as $mhs) {
echo "<tr>";
echo "<td>".$mhs->nim."</td>
<td> ".$mhs->nama."</td>
<td>".$mhs->alamat." "."</td>";
echo "</tr>";
}
echo "</table>";
}
//update
if(isset($_POST['update_nim']) and isset ($_POST['update_nama']) and isset ($_POST['update_alamat']) ){
$conn = mysqli_connect("localhost","root","","ws");
$nim = mysqli_real_escape_string($conn, $_POST['update_nim']);
$nama = mysqli_real_escape_string($conn, $_POST['update_nama']);
$alamat = mysqli_real_escape_string($conn, $_POST['update_alamat']);
//bisa and isset */
$mahasiswa_1 = $client->call("updateMahasiswa",array("nim"=>"$nim","nama"=>"$nama","alamat"=>"$alamat"));
}
?>
Comments
Post a Comment