Ver Mensaje Individual
  #17 (permalink)  
Antiguo 11/06/2016, 03:29
sergiodueso
 
Fecha de Ingreso: enero-2011
Ubicación: Zaragoza
Mensajes: 98
Antigüedad: 13 años, 7 meses
Puntos: 1
Respuesta: Error en formulario php

Esto sigue sin funcionar. Os pongo el código completo del archivo nuevo_plato.php. Gracias.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Administración Cafetería Tonik</title>
<link href="estilos.css" rel="stylesheet" type="text/css">
<style type="text/css">
#apDiv1 {
position: absolute;
width: 422px;
height: 316px;
z-index: 1;
left: 321px;
top: 148px;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
box-shadow: 5px 5px 5px #3333CC;
}
#apDiv2 {
position: absolute;
width: 405px;
height: 274px;
z-index: 2;
left: 332px;
top: 160px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
}
label {
font-family:"Times New Roman", Times, serif;
font-size:18px;
}
input {
background-color:#039;
color:#FFF;
width:250px;
height:20px;
font-family:"Times New Roman", Times, serif;
font-size:18px;
}
textarea {
background-color:#039;
color:#FFF;
width:370px;
font-family:"Times New Roman", Times, serif;
font-size:18px;
}
#precio {
background-color:#039;
color:#FFF;
width:50px;
height:20px;
font-family:"Times New Roman", Times, serif;
font-size:18px;
}
#btn_entrar {
background-color:#666;
color:#000;
width: 80px;
height: 40px;
cursor:pointer;
color:#FFF;
text-shadow: rgb(0,0,150) 3px 3px 5px;
font-family:"Times New Roman", Times, serif;
font-size:20px;
}
body {
background: -webkit-linear-gradient(20deg, #FFF, #03F);
background: -moz-linear-gradient(20deg, #FFF, #03F);
background: -o-linear-gradient(20deg, #FFF, #03F);
background: linear-gradient(20deg, #FFF, #03F);
}
#apDiv3 {
position: absolute;
width: 690px;
height: 115px;
z-index: 3;
left: 233px;
top: 5px;
text-align:center;
font-family:"Times New Roman", Times, serif;
font-size:36px;
color:#FFF;
text-shadow: rgb(0,0,150) 3px 3px 3px;
}
</style>
</head>

Código PHP:
Ver original
  1. <?php
  2. include ("../cafeteria_tonik_conexion.php");
  3. if (isset($_GET['id_mio']))
  4. {
  5.     $identificador = $_GET['id_mio'];
  6.     echo $identificador;
  7. }
  8.  
  9.  if(isset($_POST['btn_entrar']))
  10.   {
  11.      $titulo = $_POST['titulo'];
  12.      $plato = $_POST['plato'];
  13.      $precio = $_POST['precio'];
  14.      if (empty($plato))
  15.      {
  16.          echo "<script language='JavaScript'>
  17.                alert('Debes introducir un plato');
  18.                 document.location=('nuevo_plato.php');
  19.                </script>";
  20.          header('Location: nuevo_plato.php');
  21.      }
  22.      if (empty($precio))
  23.      {
  24.          echo "<script language='JavaScript'>
  25.                alert('Debes introducir un precio para este plato');
  26.                 document.location=('nuevo_plato.php');
  27.                </script>";
  28.          header('Location: nuevo_plato.php');
  29.      }
  30.   }
  31. ?>
<body>
<div id="apDiv1"></div>
<div id="apDiv2">
<form method="post" action="nuevo_plato.php">
<p>
<label for="titulo">Título del plato:</label>
<input name="titulo" type="text" id="titulo">
</p>
<p>
<label for="plato">Plato:</label>
</p>
<p>
<textarea name="plato" rows="4" cols="60"></textarea>
</p>
<p>
<label for="precio">Precio del plato:</label>
<input type="number" name="precio" id="precio" class="precio" step="any">
</p>
<p align="center">
<input id="btn_entrar" type="submit" value="Guardar" name="btn_entrar">
</p>
</form>
</div>
<div id="DivLogo">Cafetería Tonik Administración</div>

</body>
</html>