Foros del Web » Programando para Internet » PHP »

Php En El Insert Evitar Problemas!

Estas en el tema de Php En El Insert Evitar Problemas! en el foro de PHP en Foros del Web. HOLA QUE TAL A TODOS SOY NUEVO EN PHP Y EN FOROS DEL WEB QUERIA PREGUNTARLES SI ALGUIEN ME PUEDE AYUDAR CON ESTE CODIGO QUE ...
  #1 (permalink)  
Antiguo 02/03/2007, 00:11
 
Fecha de Ingreso: marzo-2007
Mensajes: 1
Antigüedad: 17 años, 2 meses
Puntos: 0
Php En El Insert Evitar Problemas!

HOLA QUE TAL A TODOS SOY NUEVO EN PHP Y EN FOROS DEL WEB QUERIA PREGUNTARLES SI ALGUIEN ME PUEDE AYUDAR CON ESTE CODIGO QUE TENGO DE INSERCION EN MI BASE DE DATOS YA QUE NO PUEDO EVITAR LA INYECCION, LES QUIERO DECIR QUE NO SOLAMENTE INGRESA DATOS SINO QUE TAMBIEN INGRESA CUALQUIER TIPO DE LETRAS,MARQUESINA,IMAGENES,ETC,ETC QUERIA SABER COMO PUEDO EVITAR ESTO??? ALGUIEN ME PUEDE AYUDAR??? MUCHAS GRACIAS!

LES PASO EL CODIGO Y SUPUESTAMENTE EL INSERT.PHP ES EL FORM K TODOS CONOCEMOS DE INGRESO:


<?php
$link = mysql_connect("localhost", "root")OR DIE("NO CONECTADO");
mysql_select_db("agenda", $link)or die("NO CONECTADO CON LA BASE");

$nombre=$_POST['nombre'];
$direccion=$_POST['direccion'];
$email=$_POST['email'];

if( isset($_POST['accion']) )
{
if( (empty($_POST['nombre'])) or (empty($_POST['direccion'])) or (empty($_POST['email'])) ){ echo'Faltan datos';
}
else { mysql_query("insert into agenda (nombre,direccion,email) values ('$nombre','$direccion','$email')",$link);
header("Location: insert.php"); }
}
?>
  #2 (permalink)  
Antiguo 02/03/2007, 07:43
Avatar de cala932  
Fecha de Ingreso: septiembre-2006
Ubicación: San Juan-Argentina
Mensajes: 902
Antigüedad: 17 años, 7 meses
Puntos: 9
Re: Php En El Insert Evitar Problemas!

No veo el problema en el insertar a la base de datos, a lo mejor habria que ver como has hecho el formulario, has probado mostrar las varibles antes de hacer el insert. Saludos
__________________
->Aprender es un proceso que incluye el error..
  #3 (permalink)  
Antiguo 02/03/2007, 07:58
Avatar de BrujoNic
Super Moderador
 
Fecha de Ingreso: noviembre-2001
Ubicación: Costa Rica/Nicaragua
Mensajes: 16.935
Antigüedad: 22 años, 5 meses
Puntos: 655
Re: Php En El Insert Evitar Problemas!

Movido desde BD a PHP.

Función de la sección de Base de Datos
__________________
La tecnología está para ayudarnos. No comprendo el porqué con esa ayuda, la gente escribe TAN MAL.
NO PERDAMOS NUESTRO LINDO IDIOMA ESPAÑOL
  #4 (permalink)  
Antiguo 02/03/2007, 09:04
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Php En El Insert Evitar Problemas!

Tu problema es que tus variables las estas insertando tal cual, para evitar que guarden cualquier cosa tienes que hacerles un tratamiento como strip_tags, htmlspecialchars, etc.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:57.