1
テキストボックスを入力した後にデータベースにデータを挿入しようとしています。私がフォームを提出するとき、それは何もしないし、なぜか分からない。これはコードです:PHPフォームの問題
<?
include("../connect537.php");
include("seguridad501.php");
include("funciones.php");
$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");
redirige('nuevapagina.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$nomproyecto?></title>
<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?' ;
eliminar=confirm(mensaje);
if (eliminar)
document.location='nuevapagina.php?act=eliminarart&id='+id;
}
</script>
</head>
<body>
<?
include("header.php");
?>
<div id="contenidototal">
<fieldset>
<div style="float:left; margin-right:25px;">
<p class="titulos">Landings Artículos</p>
</div>
<div style="float:left; width:550px;margin-top:5px;">
<form action="" method="POST" id="insertar" name="insertar">
<p><strong>Nuevo Artí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>
</form>
</div>
<div style="clear:both"></div>
<p class="texto"> </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"))){
while($f1=mysql_fetch_array($c1)){
?>
<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>
</div>
<?
}
}
?>
</fieldset>
</div>
</body>
</html>
私はそれを提出しようとすると、何もしません。私は他のパラメタと同じことをする別のページを使いました。それは完璧に動作します。その理由はわかりません。これで私を助けてくれますか?私は非常に長いので、コードの一部を省略しました。
本当にありがとうございました
注:mysqlは廃止予定です.PDOまたはmysqliを使用してください。 –
[PHPでmysql_ *関数を使用しないのはなぜですか?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php )と[PHPでのSQLインジェクションを防ぐには?](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)を参照してください。あなたのコードは古く、ハッカーの攻撃に対して非常に脆弱です。 – Oldskool
''クエリ ''のために 'if'文を使う必要はないと思います。 –