El form empieza asi
Código PHP:
<table cellspacing=0 cellpadding=0 width=98% border=0><form name="formulario" action="add.php" method="post" enctype="multipart/form-data" onSubmit="return Validar();">
Código PHP:
<tr>
<td height=14 class="texto_normal">FOTO*</td>
<td height=14 class="texto_normal"><input name="fotog" type="file" class="caja_bordenegro" id="fotog3"></td>
</tr>
Código PHP:
<?
error_reporting(E_ALL);
require("includes/conn.php");
$link = Conectarse();
$data = date ("d-m-y-H-i-s");
if($fotog_name !=""){
$strs = explode(".",$fotog_name);
$count= count($strs);
$extension = ".".$strs[$count-1];
$foto2= $data."g".$extension;
@copy($fotog,"../../fotos/$foto2");
}
$SQL="INSERT INTO productos VALUES ('', $subcategoria, '$titulo', '$cuerpo', '$precio', '$foto2', $activo )";
mysql_query($SQL, $link);
if (mysql_errno($link)==0){
}else{
if (mysql_errno($link)==1062){echo "<h2>No ha podido añadirse el registro<br>Ya existe un campo</h2>";
}else{
$numerror=mysql_errno($link);
$descrerror=mysql_error($link);
echo "Se ha producido un error nº $numerror que corresponde a: $descrerror <br>";
}
}
# cerramos la conexion
mysql_close();
?>
<script>
alert ('Se ha añadido un Producto');
window.document.location.href="index.php";
</script>
Código PHP:
<?php
function Conectarse()
{
if (!$link = mysql_connect("localhost", "++++", "*****"))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db("judeofobia",$link))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $link;
}
function cambianormal($fecha){
ereg( "([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})", $fecha, $mifecha);
$lafecha=$mifecha[3]."/".$mifecha[2]."/".$mifecha[1];
return $lafecha;
}
function cambiamysql($fecha){
ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $fecha, $mifecha);
$lafecha=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1];
return $lafecha;
}
$link=Conectarse();
?>