Charly66 Charly66 - 5 months ago 7x
HTML Question

Problems with a PHP form

I'm trying to insert data in a database after fill a text box. When I submit the form it doesn't do anything and I don't know why. This is the code:

$zona = 'nuevapagina';

if ($_POST["ins_art"]) {
echo "Pruebas";

if (mysql_query("INSERT INTO landing_articulos (id_articulo, nombre, url, h1, texto, title, description, keywords, visitas, valido) VALUES (NULL, '" . $_POST["ins_nom"] . "', '" . urls(utf8_encode($_POST["ins_nom"])) . "', '" . $h1 . "', '" . $texto . "', '" . $title . "', '" . $description . "', '" . $keywords . "', '0', '1');")) {
$idins = mysql_insert_id();
redirige('editar_nuevapagina.php?id=' . $idins);
if ($_GET["act"] == 'eliminarart' && $_GET["id"] != '') {
mysql_query("DELETE FROM `landing_articulos` WHERE `id_articulo` = " . $_GET["id"] . " LIMIT 1");

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="estilos_contenidos.css"/>
<link rel="stylesheet" type="text/css" href="estilos.css"/>
<script language="javascript">
function eliminar_art(id){
var mensaje='Deseas eliminar este articulo?' ;
if (eliminar)
<div id="contenidototal">
<div style="float:left; margin-right:25px;">
<p class="titulos">Landings Art&iacute;culos</p>
<div style="float:left; width:550px;margin-top:5px;">
<form action="" method="POST" id="insertar" name="insertar">
<p><strong>Nuevo Art&iacute;culo</strong> - Nombre: <input name="ins_nom" type="text" class="texto" id="ins_nom" /> <input name="button2" type="submit" class="texto" id="button2" value="Insertar" /><input name="ins_art" type="hidden" value="1" /></p>
<div style="clear:both"></div>
<p class="texto">&nbsp;</p>
if(mysql_num_rows($c1=mysql_query("SELECT id_articulo, nombre, url, valido FROM landing_articulos WHERE 1 ORDER BY valido DESC, nombre ASC"))){

<div style="float:left; width:32%; padding-left:0px; color:#ef5000; font-weight:bold; margin:5px;">
<p><a href="/ce-<?=$f1["url"]?>_<?=$f1["id_articulo"]?>.html" target="_blank"><strong><?=$f1["nombre"];?></strong></a> <a href="editar_nuevapagina.php?id=<?=$f1["id_articulo"]?>"><img src="imagenes/lapiz.png" width="15" height="15" border="0"/></a> </a> <a href="javascript:eliminar_pro('<?=$f1["id_articulo"]?>');"><img src="imagenes/delete.png" width="15" height="15" border="0"/></a> <? if($f1["valido"]=='0')echo ' - SIN VALIDAR';?></p>

So, when I try to submit it,don't work it doesn't anything. I used another page which I have which do the same with other parametes and it works perfectly, so I don't know why. Could you please help me with this?. I have ommited a piece of code because it would be so long.

Thanks so much


Try to get the last error with mysql_error() and then check what is going on. Maybe you are not sending some parameter or have some constrain in your database. mysql_query() only returns true/false for update/insert commands.