Comunidad de diseño web y desarrollo en internet online

POBLAR BASE DE DATOS MYSQL DESDE FLASH

Citar            
MensajeEscrito el 05 May 2009 07:28 pm
CREAMOS 7 CAMPOS DE TEXTO DINAMICO Y UN BOTON ENVIAR (nombre de instancia "tunombre, tuapellido, "tuempresa"...etc) AGREGAMOS EL SIGUIENTE CODIGO AL BOTON (nombre de instancia "submit")

Código :

on(click){
   
   tunombre = _parent._parent.write.tunombre.text;
   tuapellido = _parent._parent.write.tuapellido.text;
   tuempresa = _parent._parent.write.tuempresa.text;
   tucargo = _parent._parent.write.tucargo.text;
   tuemail = _parent._parent.write.tuemail.text;
   tutelefono = _parent._parent.write.tutelefono.text;
   tudireccion = _parent._parent.write.tudireccion.text;
   
   if (tunombre eq "") {
      _parent._parent.write.gb_status.text = "Nombre";   
   } else if (tuapellido eq "") {
      _parent._parent.write.gb_status.text = "Apellido";   
   } else if (tuempresa eq "") {
      _parent._parent.write.gb_status.text = "Empresa";            
   } else if (tucargo eq "") {
      _parent._parent.write.gb_status.text = "Cargo";
   } else if (tuemail eq "") {
      _parent._parent.write.gb_status.text = "Email";            
   } else if (tutelefono eq "") {
      _parent._parent.write.gb_status.text = "Telefono";
   } else if (!tuemail.length || tuemail.indexOf("@") == -1 || tuemail.indexOf(".") == -1) {
      _parent._parent.write.gb_status.text = "Correo inválido";
   } else if (tudireccion eq "") {
      _parent._parent.write.gb_status.text = "";
   } else {
      _parent._parent.write.gb_status.text = "cargando datos";
      newEntry = new LoadVars()
      newEntry.ref = this
      newEntry.submit = "Yes" 
      newEntry.tunombre = tunombre
      newEntry.tuapellido = tuapellido
      newEntry.tuempresa = tuempresa
      newEntry.tucargo = tucargo   
      newEntry.tuemail = tuemail
      newEntry.tutelefono = tutelefono
      newEntry.tudireccion = tudireccion 
      newEntry.sendAndLoad("http://tuurl/GuestBook1.php?action=write&r="+random(999), newEntry, "POST");
      newEntry.sendAndLoad("http://tuurl/enviobdmail1.php",newEntry,"POST");
      newEntry.onLoad = function(success){ 
         if(success){ 
            _parent._parent.write.gb_status.text = this.gb_status;
            _parent._parent.read.loadEntries("Default", 10);
            _parent._parent.write.tunombre.text = "";
            _parent._parent.write.tuapellido.text = "";
            _parent._parent.write.tuempresa.text = "";
            _parent._parent.write.tucargo.text = "";            
            _parent._parent.write.tuemail.text = "";
            _parent._parent.write.tutelefono.text = "";
            _parent._parent.write.tudireccion.text = "";
         }
      } 
   }
}

Por ignisardens

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 05 May 2009 07:32 pm
archivho PHP que escribe base de datos (GuestBook.php)


[code]
<?
$DBhost = "localhost"; // servidor
$DBuser = "userbd"; // usuario base
$DBpass = "pasbd"; // contraseña del host
$DBName = "nombrebd"; // nombre de la base de datos
$table = "guestbook"; // nombre de la tabla
$numComments = 10; // numero de comentarios por pagina

// conectando al servidor MySQL
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error en el libro de visitas: " . mysql_error());
// seleccion de MySQL servidor
mysql_select_db($DBName, $DBConn) or die("Error en el libro de visitas: " . mysql_error());

$action = $_GET['action'];

switch($action) {
case 'read' :
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error en el libro de visitas: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
$sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error en el libro de visitas: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";

if($numallComments == 0) {
print "No entries in the guestbook, as yet..";
} else {
while ($array = mysql_fetch_array($fewComments)) {
$nombre = mysql_result($fewComments, $i, 'nombre');
$apellido = mysql_result($fewComments, $i, 'apellido');
$empresa = mysql_result($fewComments, $i, 'empresa');
$cargo = mysql_result($fewComments, $i, 'cargo');
$email = mysql_result($fewComments, $i, 'email');
$telefono = mysql_result($fewComments, $i, 'telefono');
$direccion = mysql_result($fewComments, $i, 'direccion');
$time = mysql_result($fewComments, $i, 'time');

print '<b>Nombre: </b>' . $nombre . '<b>Empresa: </b>' . $empresa . '<br><b>Cargo: </b>' . $cargo . '<b>Email: </b>' . $email . '<b>Telefono: </b>' . $telefono .'<br><b>direccion: </b>' . $direccion . '<b>Apellido: </b>' . $apellido . '<br><i>Fecha: ' . $time . '</i><br><br>';
$i++;
}
}
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;

case 'write' :
$nombre = ereg_replace("&", "%26", $_POST['tunombre']);
$apellido = ereg_replace("&", "%26", $_POST['tuapellido']);
$empresa = ereg_replace("&", "%26", $_POST['tuempresa']);
$cargo = ereg_replace("&", "%26", $_POST['tucargo']);
$email = ereg_replace("&", "%26", $_POST['tuemail']);
$telefono = ereg_replace("&", "%26", $_POST['tutelefono']);
$direccion = ereg_replace("&", "%26", $_POST['tudireccion']);
$submit = $_POST['submit'];

$submitted_on = date ("Y-m-d H:i:s",time());

if($submit == 'Yes'){
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`nombre`,
`apellido`,
`empresa`,
`cargo`,
`email`,
`telefono`,
`direccion`,
`time`
)
VALUES
(\'\','
. '\'' . $nombre . '\','
. '\'' . $apellido . '\','
. '\'' . $empresa . '\','
. '\'' . $cargo . '\','
. '\'' . $email . '\','
. '\'' . $telefono . '\','
. '\'' . $direccion . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Error en el libro de visitas " . mysql_error());


print "&gb_status=Gracias, su mensaje ha sido enviado. Recibira un email de confirmacion.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
}
?>
[code]

Por ignisardens

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 05 May 2009 07:36 pm
y el php que envia correo (enviobdmail1.php)


[code]
<?php

foreach($_POST as $variable => $value)
{

if ($variable=="tunombre") {$tunombre=$value;};
if ($variable=="tuapellido") {$tuapellido=$value;};
if ($variable=="tuempresa") {$tuempresa=$value;};
if ($variable=="tucargo") {$tucargo=$value;};
if ($variable=="tuemail") {$tuemail=$value;};
if ($variable=="tutelefono") {$tutelefono=$value;};
if ($variable=="tudireccion") {$tudireccion=$value;};

}

//
$mymail .= "[email protected]";
$mymail2 .= "[email protected]";
$subject .= " estimado : ".$tunombre."\n\n";
$contenido .= " Nombre: ".$tunombre."\n\n";
$contenido .= " Apellido: ".$tuapellido."\n\n";
$contenido .= " Empresa: ".$tuempresa."\n\n";
$contenido .= " Cargo: ".$tucargo."\n\n";
$contenido .= " Email: ".$tuemail."\n\n";
$contenido .= " Telefono: ".$tutelefono."\n\n";
$contenido .= " Direccion: ".$tudireccion."\n\n";
//
$contenido .= ".";
$header = "From:".$mymail2."\nReply-To:".$mymail2."\n";
$header .= "X-Mailer:PHP/".phpversion()."\n";
$header .= "Mime-Version: 1.0\n";
$header .= "Content-Type: text/plain";
mail($mymail, $subject, utf8_decode($contenido) ,$header);
mail($tuemail, $subject, utf8_decode($contenido) ,$header);
echo "&estatus=ok&";
//}
?>



awante phixius rock chileno!

Por ignisardens

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 05 May 2009 09:58 pm
¿y todo ese codigo a que viene???



ni siquiera voy a mirar un texto asi de largo, analiza donde esta el problema y postea solo el codigo con el problema.

por ahora solo te puedo decir que pruebes si el error esta en php o en flash para esto imprime las variables POST que te lleguen en php

Código PHP :

print_r($_POST)

Por Inyaka

Claber

3176 de clabLevel

9 tutoriales
2 articulos

Genero:Masculino   Desarrollador de GAIA

Programador y fotógrafo

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.