Bueno, tengo un código que no puedo hacer encajar o.O
Osea, yo tengo el siguiente código:
Código PHP:
Ver original<?php
include ("header.php");
?>
<?php
if (!$_POST) {
?>
<center><table cellspacing="0" cellpadding="0"><form action="" method="post">
<tr>
<td><p>Titulo:</p></td>
<td style="text-align: right;"><p><input type="text" name="titulo"/></p></td>
</tr>
<tr>
<td><p>Cuerpo:</p></td>
<td style="text-align: right;"><textarea name="cuerpo"></textarea></td>
</tr>
<tr>
<tr>
<td><p>Copete:</p></td>
<td style="text-align: right;"><textarea name="copete"></textarea></td>
</tr>
<tr>
<td>Imagen:</td>
<td style="text-align: right;"><input name="imagen" type="text" id="imagen"/></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0">
<tr>
<td style="text-align: center;"><p><input type="submit" value="Publicar"/></p></td>
</tr>
</form></table></center>
<?php
} else {
$query = "insert into noticias (titulo, cuerpo, copete, imagen)
values ('" . $titulo . "', '" . $cuerpo . "', '" . $copete . "', '" . $imagen . "')";
echo "<p><center>Noticia publicada exitosamente.</p>";
echo "<p>Título: $titulo";
echo "<p>Cuerpo: $cuerpo</p>";
echo "<p>Copete: $copete</p>";
echo "<p>Imagen: $imagen</p></center>";
}
?>
<?php
include ("footer.php");
?>
Es un formulario que inserta noticias en mi base de datos,
El problema es que eso está en el panel de administración y así podría entrar cualquiera... Entonces, necesito agregarle lo siguiente...
Código PHP:
Ver original<?php
if(isset($_SESSION["s_username"]) && !empty($_SESSION["s_username"])){
echo "Contenido visible para usuarios (administrador)";
}
else{
echo "<center>ACCESO DENEGADO, <a href=index.php>LOGEATE</a> PARA ACCEDER AL PANEL DE ADMINISTRACION</center>";
}
?>
Pero el
del principio, y el
Código PHP:
Ver original<?php
} else {
$query = "insert into noticias (titulo, cuerpo, copete, imagen)
values ('" . $titulo . "', '" . $cuerpo . "', '" . $copete . "', '" . $imagen . "')";
echo "<p><center>Noticia publicada exitosamente.</p>";
echo "<p>Título: $titulo";
echo "<p>Cuerpo: $cuerpo</p>";
echo "<p>Copete: $copete</p>";
echo "<p>Imagen: $imagen</p></center>";
}
?>
del final no me dejan hacerlo :/ Alguien tiene una idea para hacer que todo funcione como debe?
Gracias de antemano