Foros del Web » Programando para Internet » PHP »

Integrar Dreamweaver con Programacion Manual en PHP

Estas en el tema de Integrar Dreamweaver con Programacion Manual en PHP en el foro de PHP en Foros del Web. Buenas noches amigos, pues eso, me gustaria saber como podria integrar dos cosas, una la he hecho con las opciones de Dreamweaver y la otra ...
  #1 (permalink)  
Antiguo 22/02/2005, 17:37
 
Fecha de Ingreso: noviembre-2003
Ubicación: Frente a la PC
Mensajes: 120
Antigüedad: 20 años, 5 meses
Puntos: 0
Pregunta Integrar Dreamweaver con Programacion Manual en PHP

Buenas noches amigos, pues eso, me gustaria saber como podria integrar dos cosas, una la he hecho con las opciones de Dreamweaver y la otra la encontre en este mismo foro, quisiera saber donde pudo meter lo q quiero en el lugar exacto..
Lo q habia hecho en Dreamweaver era hacer unos juegos de registros de modo q insertaba registros de productos, lo q me faltaba por hacer era insertarle las imagenes, de q manera? bueno, por medio del mismo formulario subirlas al servidor e insertar su nombre en la base de datos en el campo correspondiente..
Aqui les dejo los archivos..

Incluir-productos.php (hecho en Dreamweaver)

<?php require_once('../Connections/computacion.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO productos (ID_Produc, Producto, foto, foto_gnd, descripcion, ID_Cat, ID_SubCat) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID_producto'], "int"),
GetSQLValueString($_POST['producto'], "text"),
GetSQLValueString($_POST['foto'], "text"),
GetSQLValueString($_POST['foto_gnd'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['Categoria'], "int"),
GetSQLValueString($_POST['Categoria'], "text"));

mysql_select_db($database_computacion, $computacion);
$Result1 = mysql_query($insertSQL, $computacion) or die(mysql_error());

$insertGoTo = "incluir-productos.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_computacion, $computacion);
$query_ShowCat = "SELECT * FROM categorias ORDER BY Cat ASC";
$ShowCat = mysql_query($query_ShowCat, $computacion) or die(mysql_error());
$row_ShowCat = mysql_fetch_assoc($ShowCat);
$totalRows_ShowCat = mysql_num_rows($ShowCat);

mysql_select_db($database_computacion, $computacion);
$query_ShowSub = "SELECT * FROM sub_categorias ORDER BY subcat ASC";
$ShowSub = mysql_query($query_ShowSub, $computacion) or die(mysql_error());
$row_ShowSub = mysql_fetch_assoc($ShowSub);
$totalRows_ShowSub = mysql_num_rows($ShowSub);
?>
<html>
<head>
<title>Incliur Productos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/comp.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<table width="431" border="0" align="center" cellpadding="0" cellspacing="0" class="admin">
<!--DWLayoutTable-->
<tr>
<td width="429" valign="top"> <form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
<table width="428" border="0" cellpadding="0" cellspacing="0" class="admin">
<!--DWLayoutTable-->
<tr>
<td width="185" align="right" valign="middle">Producto:</td>
<td width="241" valign="middle"> <input name="producto" type="text" id="producto" size="30"></td>
</tr>
<tr>
<td align="right" valign="middle">Categoria:</td>
<td valign="middle"> <select name="Categoria" id="Categoria">
<?php
do {
?>
<option value="<?php echo $row_ShowCat['ID_Cat']?>"<?php if (!(strcmp($row_ShowCat['ID_Cat'], $row_ShowCat['ID_Cat']))) {echo "SELECTED";} ?>><?php echo $row_ShowCat['Cat']?></option>
<?php
} while ($row_ShowCat = mysql_fetch_assoc($ShowCat));
$rows = mysql_num_rows($ShowCat);
if($rows > 0) {
mysql_data_seek($ShowCat, 0);
$row_ShowCat = mysql_fetch_assoc($ShowCat);
}
?>
</select></td>
</tr>
<tr>
<td align="right" valign="middle">SubCategoria:</td>
<td valign="middle"> <select name="SubCategoria" id="SubCategoria">
<?php
do {
?>
<option value="<?php echo $row_ShowSub['ID_SubCat']?>"<?php if (!(strcmp($row_ShowSub['ID_SubCat'], $row_ShowSub['ID_SubCat']))) {echo "SELECTED";} ?>><?php echo $row_ShowSub['subcat']?></option>
<?php
} while ($row_ShowSub = mysql_fetch_assoc($ShowSub));
$rows = mysql_num_rows($ShowSub);
if($rows > 0) {
mysql_data_seek($ShowSub, 0);
$row_ShowSub = mysql_fetch_assoc($ShowSub);
}
?>
</select></td>
</tr>
<tr>
<td valign="middle"><div align="right">Nombre de la miniatura: </div></td>
<td valign="middle"><input name="foto" type="text" id="foto" size="30"></td>
</tr>
<tr>
<td valign="middle"><div align="right">Nombre de imagen principal: </div></td>
<td valign="middle"><input name="foto_gnd" type="text" id="foto_gnd" size="30"> </td>
</tr>
<tr>
<td valign="middle"><div align="right">Descripci&oacute;n:</div></td>
<td valign="top"><textarea name="descripcion" cols="30" wrap="VIRTUAL" id="descripcion"></textarea></td>
</tr>
<tr>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="top"><input name="Submit" type="submit" onClick="MM_validateForm('producto','','R');return document.MM_returnValue" value="Enviar">
<input name="ID_producto" type="hidden" id="ID_producto2"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1">
</form></td>
</tr>

</table>
</body>
</html>
<?php
mysql_free_result($ShowCat);

mysql_free_result($ShowSub);
?>



Rchivo para solo subir imagenes al servidor y escribir su nombre en la base de datos. subir.php (programado manualmente por un compañero de este foro llamado Ludwingg, gracias amigo.. )

<?
if(!$enviar){
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="archivo"><br>
<input type="file" name="archivos"><br>
<input type="submit" name="enviar" value="enviar">
</form>
<?
}else{
$conexion=mysql_connect("localhost","","");
mysql_select_db("test",$conexion);
//
$nombre=$_FILES['archivo']['name'];
$tipo=$_FILES['archivo']['type'];
$tamaño=$_FILES['archivo']['size'];
//
$nombre1=$_FILES['archivos']['name'];
$tipo1=$_FILES['archivos']['type'];
$tamaño1=$_FILES['archivos']['size'];
//
if (move_uploaded_file($_FILES["archivo"]["tmp_name"], "carpeta/" . $_FILES["archivo"]["name"]) && move_uploaded_file($_FILES["archivos"]["tmp_name"], "carpeta/" . $_FILES["archivos"]["name"])){
echo "bien";
mysql_query("Insert into tabla(foto0,foto1) values('$nombre','$nombre1')");
}
else{
echo "error";
}
}
?>


Bueno, eso es todo.. gracias...
__________________
Sin sombra no hay luz...
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 18:16.