Os dejo el codigo que e echo pero no se como dejarlo bien, porfavor una ayuda :)
agregar_noticia.php
Código PHP:
<form id="form1" name="form1" method="post" action="agregar_noticia.php">
<table width="315" cellpadding="0" cellspacing="2">
<tr>
<td width="19" bgcolor="#333333"> </td>
<td width="63" class="letra_general">Titulo:</td>
<td width="224"><input name="titulo" type="text" id="titulo" /></td>
</tr>
<tr>
<td bgcolor="#333333"> </td>
<td class="letra_general">Cuerpo:</td>
<td><input name="cuerpo" type="text" id="cuerpo" /></td>
</tr>
<tr>
<td bgcolor="#333333"> </td>
<td class="letra_general">Fecha:</td>
<td><input name="fecha" type="text" id="fecha" /></td>
</tr>
<tr>
<td bgcolor="#333333"> </td>
<td class="letra_general">Enlace:</td>
<td><input name="enlace" type="text" id="enlace" /></td>
</tr>
<tr>
<td bgcolor="#333333"> </td>
<td class="letra_general">Foto:</td>
<td><input name="foto" type="file" id="foto" /></td>
</tr>
</table>
</form>
<table width="315" height="107" cellpadding="0" cellspacing="1">
<tr>
<td>
<?
//Metemos un mensaje de error
$me ="";
if ( (!isset($_POST['titulo'])) || ($_POST['titulo'] == "")){
$me.="Falta insertar el titulo de la noticia <br>";
}
?>
</td>
</tr>
<tr>
<td><? if ( (!isset($_POST['cuerpo']) || $_POST['cuerpo'] == "")){
$me.="Falta insertar el cuerpo de la noticia <br>";
} ?></td>
</tr>
<tr>
<td><? if ( (!isset($_POST['fecha']) || $_POST['fecha'] == "")){
$me.="Falta insertar la fecha <br>";
} ?></td>
</tr>
<tr>
<td><? if ( (!isset($_POST['enlace']) || $_POST['enlace'] == "")){
$me.="Falta insertar el enlace <br>";
} ?></td>
</tr>
<tr>
<td><? if ( (!isset($_POST['foto']) || $_POST['foto'] == "")){
$me.="Falta insertar la foto <br>";
} ?>
<?
if ($me ==""){
$titulo = $_POST['titulo'];
$cuerpo = $_POST['cuerpo'];
$fecha = $_POST['fecha'];
$enlace = $_POST['enlace'];
$foto = $_POST['foto'];
// Nos conectamos
$conexion = mysql_connect ("localhost", "n0ck", "224100") or die ('No se puede conectar a la base de datos, error: ' . mysql_error());
mysql_select_db ("db_n0ck");
// Hacemos la iserción
mysql_query("INSERT INTO noticias ( id, titulo, cuerpo, fecha, enlace)
VALUES ('','$titulo', '$cuerpo', '$fecha', '$enlace')");
mysql_close();
}
else{
echo($me);
} ?></td>