Post your results in the
- Code: Select all
[spoiler]your answers[/spoiler]
You may post additional information such as what you believe this coder could have done to secure his code.
Once there has been a fair number of results, I will break the code down as well as the correct answers and will provide a security lesson based on the vulnerabilities within this cdoe.
- Code: Select all
<?php
if (!$categoria = $_POST['categoria'])
{
mensaje("campo_txt", "Agregar Categoria", "../agregar_categoria.php", "", "", "");
}
$sql_gemelo = " SELECT * FROM tbl_categorias WHERE col_titulo = '" . $_POST['categoria'] . "' ";
$rs = mysql_query($sql_gemelo);
$num = mysql_num_rows($rs);
if ($num !== 0)
{
mensaje("gemelo", "Agregar Categoría", "../agregar_categoria.php", "la categoría", "", "");
}
chdir("../..");
$dir_categoria = $categoria;
$base = "img/espanol/producto/$dir_categoria";
if (!@mkdir("$base"))
{
die("NueCat.-.ERROR MKDIR $categoria");
}
$consulta = "INSERT INTO tbl_categorias VALUES('','" . $categoria . "')";
if (!@mysql_query($consulta))
{
die("NueCat.-.ERROR MYSQL " . mysql_error());
}
$url = "location:../agregar_subcategoria.php?NOMBRE_CATEGORIA=$categoria&RUTA=$base";
header($url);
?>

















