Você está na página 1de 5

LABORATORIO N 07

ESCUELA : INGENIERIA DE SISTEMAS


ASIGNATURA : COMPUTACION MOVIL
CICLO : VII
TURNO : Maana
SEMESTRE : 2014-I
DOCENTE : ING. LUIS RAMOS MENDOZA
Alumno

TEMA: Conectividad a un servidor Web


DESARROLLO:
Proceso de instalacin del servidor Web
Ingresar a la consola del MYSQL
Realizar lo siguiente en Mysql
Mysql> create database ucvdata;
Mysql> use ucvdata;
Mysql> show databases;
Crear la tabla Alumnos:

Ingresar los siguientes Datos en la tabla alumnos





Codifica la Pagina Web en PHP
Crear una pgina web con el nombre de listado.php
Ingresar al editor de texto del men de accesorios

<html>
<head>
<title>Ejemplo de PHP</title>
</head>
<body>
<?php
function Conectarse()
{
if (!($link=mysql_connect("localhost","root","")))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db("ucvdata",$link))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $link;
}
$link=Conectarse();
echo "Conexin con la base de datos conseguida.<br>";

$result=mysql_query("select * from alumnos",$link);
?>
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 align=center>
<TR><TD> codigo</TD><TD> Apellidos </TD></TR>
<?php

while($row = mysql_fetch_array($result))
{
echo "<tr><td width=100>".$row[0]."</td><td
width=200>".$row[1]."</td></tr>";
}
mysql_free_result($result);
mysql_close($link);
?>
</table>
</body>
</html>



Configurar la URL del servidor web con un numero IP esttico
Realizar la prueba de conexin haciendo uso de ping desde la mquina del emulador hacia la
mquina del servidor web

PROBLEMAS PROPUESTOS
Las pginas de transaccin no deben contener diseo web

1. Crear una pgina web llamada ingreso.php, enviar los datos a la pgina guardar.php, la
cual se encargar de registrar los datos en la base de datos

2. Crear una pgina web con el nombre de consulta.php
Ingresar el cdigo del alumno en consulta.php y mostrar sus datos en la pgina
mostrardatos.php



3. Crear una pgina web con el nombre de eliminar.php
Ingresar el cdigo del alumno en eliminar.php enviar el cdigo a la pgina
eliminadata.php, la cual se encargara de borrar el registro en la base de datos


4. Crear una pgina web men.php, permitir mostrar las opciones para manipular las
pginas webs

DESARROLLO DE UNA APLICACIN aNDROID

1. Crear una aplicacin para android y modificar el archivo manifest.xml


2. Agregar una clase llamada HttpConfig con el siguiente cdigo

import org.apache.http.HttpEntity;
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.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class httpConfig {
public String post(String url){
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);

//AADIR PARAMETROS
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("txtcod","W0001"));
params.add(new BasicNameValuePair("txtape","LOPEZ QUISPE"));

httppost.setEntity(new UrlEncodedFormEntity(params));

HttpResponse resp = httpclient.execute(httppost);

HttpEntity entidad = resp.getEntity();
String text = EntityUtils.toString(entidad);
return text;
}
catch(Exception e)
{ return "error";}

}



3. Agregar una clase llamada HttpConfig con el siguiente cdigo

//instanciar la clase httpConfig en la clase MainActivity

httpConfig obj = new httpConfig();

//en el metodo OnCreate

String txt = obj.post("http://192.168.0.10/mostrardatos.php");
TextView txtmsn = (TextView)findViewById(R.id.text1);
txtmsn.setText(txt);

4. Realizar el diseo del layout, que permita en ingreso del cdigo y apellido del alumno,
los datos sern enviados al mtodo post de la clase HttpConfig para su consulta
respectiva.

PROBLEMA PROPUESTO
Completar la aplicacin de tal manera que permita hacer un mantenimiento de datos sobre la
tabla alumnos
Ingreso de datos
Consulta
Eliminar
Actualizar
Listado

Você também pode gostar