<?php $galleria_id=$_POST['cat']; if (isset($_POST['name'])) { $name=sanitize($_POST['name']); $texto=sanitize($_POST['texto']); } $query = "INSERT INTO eventogaleria (galleria_id,name,texto)" . " VALUES ('$galleria_id','$name','$texto')"; $result = mysql_query($query) or die('Unable to add product'); if ($result) echo "<h2>Una Nueva Foto ha sido anadida al album</h2>\n"; else echo "<h2>Ha habido un problema andaidiendo tu foto.</h2>\n"; ?>
<?php function sanitize($data) { // remove whitespaces (not a must though) $data = trim($data); // apply stripslashes if magic_quotes_gpc is enabled if(get_magic_quotes_gpc()) { $data = stripslashes($data); } // a mySQL connection is required before using this function $data = mysql_real_escape_string($data); return $data; } ?>