viernes, 27 de marzo de 2015

Ingreso de datos PHP

<!--Tabla para cargar noticias en la BD-->
<html>
<head>
</head>
<body>
 <form action = "noticia_guardar.php" method = "POST">
  <table align = "center" style = "cellpadding 10px; cellspacing: 10px;">
   <tr>
    <td>Titulo:</td>
    <td><input type = "text" name= "titulo" style  = "width: 100%"/></td>
   </tr>
   <tr>
    <td>Noticia:</td>
    <td><textarea name = "cuerpo" rows = "5" cols = "60"></textarea> </td>
   </tr>
   <tr>
    <td><input type = "submit" value = "Ingresar Datos"/></td>
   </tr>
  </table>
 </form> 
</body>
</html>


//Ingreso de datos a la BD 
<?php
  include("conexion.php");

  $titulo = $_POST['titulo'];
  $cuerpo = $_POST['cuerpo'];

  if(isset($titulo) && !empty($titulo) &&
     isset($cuerpo) && !empty($cuerpo))
 {
  $sql = "INSERT INTO noticia (titulo, cuerpo) VALUES ('$titulo','$cuerpo')";
   mysql_query($sql);
   header("Location: admin.php");
 }
?>

No hay comentarios:

Publicar un comentario