Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/11/2010, 06:43
leadtube
 
Fecha de Ingreso: febrero-2010
Mensajes: 4
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Como cargar base de datos desde un formulario

ACA LO REENVIO CON ESPACIOS ENTRE LOS CODIGOS PARA QUEPUEDAN LEER BIEN:




Hola a Todos,
Tengo una pequeña base de datos en php 5.o mysql hospedada en godaddy Linux.
Para guardar el tipo de cambio del dólar compra y venta junto con la fecha y hora, alimentada desde un formulario,
PERO NO ME ESTAFUNCIONANDO, ME SALE ERROR, ME PUEDEN AYUDAR POR FAVOR?

ESTE ES EL ERROR QUE ME SALE: http://www.grupocomecacr.com/tipocambiodiario/error.php?error=60
Page Not Found

POR FAVOR ALGUIEN QUE ME ORIENTE....... (CONTACTO: [email protected] )

EL SISTEMA QUE HE CREADO TIENE:
1.un formualrio en línea
2. un action del formulario que esta supuesto a cargar la base de datos
3. una pagina de gracias donde debe terminar la acción y se da clic para ir a meter mas datos:
/////
/
/
/


LOS CODIGOS SON:
FORMULARIO:
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
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=document.getElementById(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>
<style type="text/css">
<!--
#form1 table tr td {
color: #00F;
}
#form1 table {
color: #FFF;
}
.meenu {
text-align: center;
}
.peq {
font-size: xx-small;
}
.enca {
text-align: center;
}
-->
</style>

<p class="enca">Grupo Comeca Costa Rica - <a href="http://www.grupocomecacr.com">www.grupocomecacr.com</a></p>
<p class="enca">ALIMENTADOR TIPO DE CAMBIO DIARIO (a una base de datos)</p>
<form action="postinfo.php" method="post" name="form1" id="form1" onsubmit="MM_validateForm('compra','','RinRange1:9 999','venta','','RinRange1:9999');return document.MM_returnValue">
<table width="200" align="center">
<tr>
<td bgcolor="#FFFFFF">Fecha:</td>
<td bgcolor="#FFFFFF">la coloca el sistema junto con la hora</td>
</tr>
<tr>
<td>Compra</td>
<td><label>
<input name="compra" type="text" id="compra" onblur="MM_validateForm('compra','','RinRange1:999 9');return document.MM_returnValue" size="6" />
</label></td>
</tr>
<tr>
<td>Venta</td>
<td><label>
<input name="venta" type="text" id="venta" onblur="MM_validateForm('venta','','NinRange1:9999 ');return document.MM_returnValue" size="6" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Enviar" />
<input type="reset" name="button2" id="button2" value="Borrar" />
</label></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<table width="637" align="center">
<tr>
<td width="157" class="meenu"><a href="http://www.grupocomecacr.com">Ir a Grupo Comeca CR</a></td>
<td width="119" class="meenu"><a href="http://www.grupocomecacr.com/tipocambiodiario/tipocambio.html">Ver datos</a></td>
<td width="82" class="meenu"><a href="http://www.grupocomecacr.com/tipocambiodiario/tipocambio-alimentador.html">Reset</a></td>
<td width="259"><a href="https://p3nlmysqladm001.secureserver.net/dgrid50/9/index.php?lang=es-iso-8859-1&amp;convcharset=iso-8859-1&amp;collation_connection=utf8_unicode_ci&amp;tok en=76c6580a6a28d0770070486d14ab553b">Editar / Exportar - Base de datos</a></td>
</tr>
</table>
<p>&nbsp;</p>
<p class="peq">por: <a href="http://www.tuwebcr.com">Dise&ntilde;o y Mercadeo Web TuWebCR.com</a></p>
<p>&nbsp;</p>
/
/
/
/

EL ACTION DEL FORMUALRIO (postinfo.php) TIENE ESTE CODIGO:
<?php
$hostname = "tipocambio.db.6691923.hostedresource.com";
$db_user = "XXXXXXXXXXXXXXXXXX";
$db_password = "XXXXXXXXXXXXXXXXXXXX";
$db_table = "cambiodiario";


$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($db_table,$db);
?>
<?php
$date = date("Y-m-d H:i:s");
$compra = $_POST['compra'];
$venta = $_POST['venta'];
?>
<?php
if (isset($_REQUEST['Submit']))
{
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(fecha, compra, venta) values ('$date','$compra','$venta')";
$result = mysql_query($sql ,$db);
echo "Gracias, La informacion a entrado a la base de datos";
header("location: http://www.grupocomecacr.com/tipocambiodiario/gracias.html");
exit();
}
else
{
header("location: error.php?error=60");
exit();
}
?>
/
/
/
/


LA PAGINA DE GRACIAS DONDE DEBE FINALIZAR LA ACCION ES:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.gra {
text-align: center;
}
.gra {
font-size: xx-large;
}
-->
</style>
</head>

<body>
<p class="gra">&nbsp;</p>
<p class="gra">&nbsp;</p>
<p class="gra">&nbsp;</p>
<p class="gra"><span class="gra">Gracias</span></p>
<p class="gra"><span class="gra"><a href="http://www.grupocomecacr.com/tipocambiodiario/tipocambio-alimentador.html">Cargar Otros datos</a></span><a href="http://www.grupocomecacr.com/tipocambiodiario/tipocambio-alimentador.html"></a></p>
<p>&nbsp;</p>
</body>
</html>