IngDeportista.php
Código PHP:
<?php
include "libreria/recursos.php";
include "libreria/cls_Deportista.php";
include "Manejadores/ManejadorDeportista.php";
$deportista = new Deportista();
//$deportista->IdDeportista = 0;
if($_POST){
$deportista->IdDeportista = $_POST["txtCod"];
$deportista->Nombre = $_POST["txtNombre"];
$deportista->Apellido= $_POST["txtApellido"];
$deportista->Sexo = $_POST["selectSexo"];
$deportista->FechaNacimiento = $_POST["FechaNacimiento"];
$deportista->Pais = $_POST["txtPais"];
$deportista->Ciudad = $_POST["txtCiudad"];
$deportista->Email = $_POST["txtEmail"];
$deportista->NombreDeporte = $_POST["txtNombreDeporte"];
$deportista->Disciplina = $_POST["txtDisciplina"];
$deportista->Altura = $_POST["txtAltura"];
$deportista->Peso = $_POST["txtPeso"];
$deportista->FanPage = $_POST["txtFanPage"];
$deportista->Twitter = $_POST["txtTwitter"];
$deportista->Implementos = $_POST["Implementos"];
$deportista->Financiamiento = $_POST["Financiamiento"];
$deportista->Convenios = $_POST["Convenios"];
$deportista->Otros = $_POST["txtOtros"];
$deportista->Participacion = $_POST["Torneos"];
ManejadorDeportista::guardarDeportista($deportista);
header("location:listaDeportista.php");
}
else
if(isset($_GET["Id"]))
{
//$deportista->IdDeportista = $_GET["Id"]
$deportista = ManejadorDeportista::cargarDeportista($deportista);
}
?>
<html>
<head>
<title>Deportista</title>
<link rel='stylesheet' type='text/css' href='menu_style.css' />
</head>
<style>
fieldset{
width:150px;
}
</style>
<body>
<div align="center">
<ul class="menu red">
<li class="current"><a href="Home.php" title="">Inicio</a></li>
<li><a href="#" title=""></a></li>
<li><a href="IngDeportista.php" title="">Insertar Deportista</a></li>
<li><a href="listaDeportista.php" title="">Listar Deportistas</a></li>
<li><a href="listaDeportista.php" title="">Actualizar Deportista</a></li>
<li><a href="listaDeportista.php" title="">Eliminar Deportistas</a></li>
<li><a href="logout.php" style="background-color:#5bb8c4 " title="">Cerrar Sesion</a></li>
<li><a href="" title=""></a></li>
</ul>
</div>
<center>
<fieldset>
<legend>Ingrese un Nuevo Deportista</legend>
<form method="post" action="">
<table border= 0 align="center">
<tbody>
<tr>
<td>
Nombre:
</td>
<td>
<input name="txtNombre" type="text" size="30" maxlength="30" value="<?php echo $deportista->Nombre;?>"required="required">
</td>
<td>
Nombre del Deporte:
</td>
<td>
<input name="txtNombreDeporte" type="text" size="30" maxlength="30" value="<?php echo $deportista->NombreDeporte;?>"required="required">
</td>
</tr>
<tr>
<td>
Apellido:
</td>
<td>
<input name="txtApellido" type="text" size="30" maxlength="30" value="<?php echo $deportista->Apellido;?>"required="required">
</td>
<td>
Disciplina:
</td>
<td>
<input name="txtDisciplina" type="text" size="30" maxlength="30"value="<?php echo $deportista->Disciplina;?>"required="required">
</td>
</tr>
<tr>
<td>
Sexo:
</td>
<td>
<select name="selectSexo" required="required">
<option selected="selected" value="Masculino">Masculino</option>
<option value="Femenino">Femenino</option>
</select>
</td>
<td>
Altura:
</td>
<td>
<input name="txtAltura" type="text" size="30" maxlength="30"required="required" value="<?php echo $deportista->Altura;?>" placeholder="1.10">
</td>
</tr>
<tr>
<td>
Fecha Nacimiento:
</td>
<td>
<input type="date" name="FechaNacimiento" value="<?php echo $deportista->FechaNacimiento;?>" requiered="requiered">
</td>
<td>
Peso:
</td>
<td>
<input name="txtPeso" type="text" size="30" maxlength="30" value="<?php echo $deportista->Peso;?>"required="required">
</td>
</tr>
<tr>
<td>
Pais:
</td>
<td>
<input name="txtPais" type="text" size="30" maxlength="50"value="<?php echo $deportista->Pais;?>"required="required">
</td>
<td>
¿FanPage?
</td>
<td>
<input name="txtFanPage" type="text" size="30" maxlength="50"value="<?php echo $deportista->FanPage;?>"required="required">
</td>
</tr>
<tr>
<td>
Ciudad:
</td>
<td>
<input name="txtCiudad" type="text" size="30" maxlength="50"value="<?php echo $deportista->Ciudad;?>"required="required">
</td>
<td>
¿Twitter?
</td>
<td>
<input name="txtTwitter" type="text" size="30" maxlength="50"value="<?php echo $deportista->Twitter;?>" required="required">
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<input type="email" name="txtEmail" size="30" value="<?php echo $deportista->Email;?>"required placeholder="[email protected]">
</td>
<td>
¿Que buscas de Deportistas Online ?
</td>
<td>
<input type="checkbox" name="Implementos" id="chkImplementos" value="Implementos Deportivos" ></input><label>Implementos Deportivos</label>
<br>
<input type="checkbox" name="Financiamiento"id="chkFinanciamiento" value="Financiamiento" ></input><label>Financiamiento</label>
<br>
<input type="checkbox" name="Convenios" id="chkConvenios" value="Convenios" ></input><label>Convenios</label>
<br>
<label>Otros</label>
<input name="txtOtros" type="text" size="30" value="<?php echo $deportista->Otros;?>" maxlength="50">
</td>
</tr>
<tr>
<td>
</td>
<td>
<!-- <input type="file" name="Foto" /> -->
</td>
<td>
Participacion en Torneos:
</td>
<td>
<textarea name="Torneos" cols="40" rows="5"></textarea>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="Guardar"/>
</td>
</tr>
</tbody>
</table>
</form>
</fieldset>
</center>
<div align="center">
<ul class="menu red">
<li class="current"><a title="">CGCE S.A</a></li>
</ul>
</div>
</body>
</html>
Código PHP:
<?php
class ManejadorDeportista {
static function guardarDeportista($Deportista)
{
if($carlos)
{
$consulta = "insert into Deportista(Nombre, Apellido, Sexo, FechaNacimiento, Pais, Ciudad, Email) values('{$deportista->Nombre}','{$deportista->Apellido}','{$deportista->Sexo}','{$deportista->FechaNacimiento}','{$deportista->Pais}','{$deportista->Ciudad}','{$deportista->Email}');";
$resultado = mysql_query($consulta);
if(mysql_affected_rows()==0)
{
$carlos = false;
echo 'false1';
}
else
{
$carlos = true;
$consulta0="SELECT MAX(IdDeportista) AS IdDeportista FROM Deportista";
$resultado0 = mysql_query($consulta0,$conexion);
if($re=mysql_fetch_array($resultado0)){
$carlos = true;
}else{
$carlos = false;
echo 'false12';
}
}
if($carlos)
{
$consulta2 = "insert into DatosDeporte(IdDeportista, NombreDeporte, Disciplina, Altura, Peso, FanPage, Twitter, Implementos, Financiamiento, Convenios, Otro, Participacion) values(".$re['IdDeportista'].",'$nombreDeporte','$disciplina',$altura,$peso,'$fanPage','$twitter','$implementos','$financiamiento','$convenio','$otro','$torneos')";
$resultado2 = mysql_query($consulta2, $conexion);
if(mysql_affected_rows()==0)
{
$carlos = false;
echo 'false2';
}
else
{
$carlos= true;
}
}
}
}
static function mostrarDeportista(){
$sql="select Deportista.IdDeportista, Nombre, Apellido, Sexo, date_format(FechaNacimiento, '%d-%m-%Y'), Pais, Ciudad, Email, NombreDeporte, Disciplina, Altura, Peso, FanPage, Twitter, Implementos, Financiamiento, Convenios, Otro, Participacion from Deportista, DatosDeporte WHERE Deportista.IdDeportista = DatosDeporte.IdDeportista;";
$resultado = mysql_query($sql);
return $resultado;
}
static function cargarDeportista($deportista){
$sql = "select * from Deportista where `IdDeportista` = '{$deportista->IdDeportista}'";
$resultado = mysql_query($sql);
if(mysql_num_rows($resultado) > 0)
{
$fila = mysql_fetch_assoc($resultado);
$deportista->IdDeportista= $fila['IdDeportista'];
$deportista->Nombre = $fila['Nombre'];
$deportista->Apellido = $fila['Apellido'];
$deportista->Sexo = $fila['Sexo'];
$deportista->FechaNacimiento = $fila['FechaNacimiento'];
$deportista->Pais = $fila['Pais'];
$deportista->Ciudad = $fila['Ciudad'];
$deportista->Email = $fila['Email'];
return $deportista;
}
}
static function eliminarDeportista($deportista){
$sql = "DELETE FROM Deportista WHERE IdDeportista ='{$deportista->IdDeportista}';";
mysql_query($sql);
}
}
?>
http://imageshack.com/a/img35/7056/vasr.jpg