jueves, 21 de agosto de 2014

Practica 1


Deberas accesar a la aplicacion de Java Netbeans, Seleccionar la opcion de File, New Project de tipo HTML y escribir el siguiente codigo:


Ejecutaras la aplicacion con la tecla F6 o con la flecha verde que se encuentra en la parte superior y podras visualizar en el navegador que tengas, una pagina como la siguiente:


altas.html

<html>
    <head>
        <title>Practica1</title>

    </head>
    <body>
        <form method="post" action="altas.php">
            Alumnos de la Universidad Isaac Newton Atlacomulco
            <br>
            Por favor ingresa tus datos:
            <br>
            Nombre:<input name="nombreal" type="text" value=""/><br>
            Direccion: <input name="diral" type="text" value=""/><br>
            Telefono: <input name="telal" type="text" value=""/><br>
            Edad: <input name="edadal" type="text" value=""/><br>
            Sexo: <input name="sexoal" type="text" value=""/><br>
            Semestre: <input name="semestreal" type="text" value=""/><br>
            Carrera: <input name="carreraal" type="text" value=""/><br>
            <br><br>
            <input type="submit" value="Guardar">
           
           
        </form>  
    </body>
</html>

altas.php

<html>
<?php
include ("conexion.php");
//echo "nombre "; echo $_POST['nombreal']; echo "<br/>";
//echo "dir: "; echo $_POST['diral']; echo "<br/>";
//echo "tel: "; echo $_POST['telal']; echo "<br/>";
$nombreal=$_POST['nombreal'];
$diral=$_POST['diral'];
$telal=$_POST['telal'];
$edadal=$_POST['edadal'];
$sexoal=$_POST['sexoal'];
$semestreal=$_POST['semestreal'];
$carreraal=$_POST['carreraal'];

$insercion=mysql_query("Insert into alumnos (nombre, direccion, telefono, edad, sexo, semestre, carrera) values ('$nombreal', '$diral', '$telal', '$edadal', '$sexoal', '$semestreal', '$carreraal')", $conexion);

if($insercion)
{
echo "Se inserto el registro exitosamente";
}
else
{
echo "Ocurrio un error el registro no fue insertado correctamente";
}
?>
    <form action="menu.html">
    <input type="submit" value="Menu Principal">
    </form> 
</html>

bajas.html

<html>
      <head>
        <title>Bajas</title>

    </head>
    <body>
        <form method="post" action="bajas.php">
            Baja de alumnos de la Universidad Isaac Newton Atlacomulco
            <br>
            Por favor ingresa la clave del alumno que desea darse de baja:
            <br>
            Clave:<input name="claveal" type="text" value=""/><br>
          
            <br><br>
            <input type="submit" value="Borrar">
           
           
        </form>  
    </body>
</html>

bajas.php

<html>
<?php

include ("conexion.php");

$clave=$_POST['claveal'];

$borrado=mysql_query("Delete from alumnos where idalumno=$clave");

if($borrado)
{
echo "Se borro el registro exitosamente";
}
else
{
echo "Ocurrio un error";
}
?>
    <form action="menu.html">
    <input type="submit" value="Menu Principal">
    </form>
</html>

conexion.php

<html>
<?php

include ("conexion.php");

$clave=$_POST['claveal'];

$borrado=mysql_query("Delete from alumnos where idalumno=$clave");

if($borrado)
{
echo "Se borro el registro exitosamente";
}
else
{
echo "Ocurrio un error";
}
?>
    <form action="menu.html">
    <input type="submit" value="Menu Principal">
    </form>
</html>

consultas.html

<html>
      <head>
        <title>Consultas</title>

    </head>
    <body>
        <form method="post" action="consultas.php">
            Consulta de alumnos de la Universidad Isaac Newton Atlacomulco
            <br>
            Por favor ingresa la clave del alumno que desea consultas:
            <br>
            Clave:<input name="claveal" type="text" value=""/><br>
          
            <br><br>
            <input type="submit" value="Consultar">
           
           
        </form>  
    </body>
</html>

consultas.php

<html>
<?php

include ("conexion.php");

$clave=$_POST['claveal'];

$consultas=mysql_query("Select * from alumnos where idalumno=$clave");

while ($row = mysql_fetch_row($consultas)){

echo      "<tr>

<td>".$row[0]."</td>

<td>".$row[1]."</td>

<td>".$row[2]."</td>

<td>".$row[3]."</td>

<td>".$row[4]."</td>

<td>".$row[5]."</td>

<td>".$row[6]."</td>

<td>".$row[7]."</td>

</tr>";

}

?>
    <form action="menu.html">
    <input type="submit" value="Menu Principal">
    </form>
</html>