RE: [PHP-DB] INSERT img+ID

[email protected] ("Chris Verges")
Newsgroups php.db
Message-ID <68FBE0F3CE97264395875AC1C468F22C05F5B3@mail03.cyberswitching.local>
Hi Emiliano,

You may want to look at escaping your $_POST, $_REQUEST, and $_GET variables before using them in their raw form.  Otherwise, you may be susceptible to SQL injection attacks.

http://us2.php.net/mysql_escape_string

This may also affect the upload of your binary data using SQL, since it is very possible for binary data to contain delimiter characters (', ", etc.)

Good luck,
Chris




-----Original Message-----
From: Emiliano Boragina [mailto:[email protected]]
Sent: Sat 1/24/2009 5:01 AM
To: [email protected]
Subject: [PHP-DB] INSERT img+ID
 
Hi I have this PHP:

 

<?php 

if(isset($_POST["nombre"]) && isset($_POST["localidad"]) &&
isset($_POST["mail"]) && isset($_POST["nombCreacion"]) &&
isset($_POST["imagen_txt"]) )

{

            $nombre = $_REQUEST["nombre"];

            $localidad = $_REQUEST["localidad"];

            $email = $_REQUEST["mail"];

            $nomCreacion = $_REQUEST["nombCreacion"];

            $creacion = $_REQUEST["imagen_txt"];

            $habilitar = 0;

            $votos = 0;

            

            $base = 'mydb';

            $conexion = mysql_connect ( 'localhost' , 'root' , 'root' );

            mysql_select_db ( $base , $conexion );

                        

            mysql_query ( "INSERT INTO fotografias
(nombre,localidad,email,nomCreacion,creacion,habilitar,votos) VALUES (
'$nombre' , '$localidad' , '$email' , '$nomCreacion' , '$creacion' ,
'$habilitar' , '$votos' )", $conexion);

            

            

            $fecha = date("D-M-y H:i");

            $mymail = "[email protected]";

            $subject = "Contact Form"."<br>"; 

            $contenido .= "Nombre y Apellido: ".$_POST["nombre"]."<br>";

            $contenido .= "Localidad: ".$_POST["localidad"]."<br>";

            $contenido .= "Mail de tus papas: ".$_POST["mail"]."<br>";

            $contenido .= "Nombre de la creaci&oacute;n:
".$_POST["nombCreacion"]."<br>";

            $contenido .= "Foto: <a href='fotos/".$_POST["imagen_txt"]."'>
fotos/".$_POST["imagen_txt"]."</a><br>";

            $contenido .= "Habilitar o Borrar creaci&oacute;n: <a
href='admin/'>Administrador</a><br>";

            $contenido .= "El mensaje se escribio el ".$fecha."<br>"; 

            $header =
"From:".$_POST["mail"]."\nReply-To:".$_POST["mail"]."<br>";

            $header .= "X-Mailer:PHP/".phpversion()."\n"; 

            $header .= "Mime-Version: 1.0\n"; 

            $header = "Content-Type: text/html; charset=utf-8\r\n";

            mail($mymail, $subject, utf8_encode($contenido) ,$header);

            

            echo 'exito=true';

}else{

            echo "nada subio";

}

 

?>

 

I want to insert a JPG image ($creacion) with the ID (from the data base,
MEDIUMINT AUTOINCREMENT): 23image.jpg in the data base, and send the
information to a e-mail addres. How do I do that?

Thanks a lot,

 

+                                                                          _
   // Emiliano Boragina _
   // Diseño & Comunicación //////////////////
+                                                                          _
   // [email protected]  /
   // 15 40 58 60 02 ///////////////////////////
+                                                                          _
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.