Ver Mensaje Individual
  #9 (permalink)  
Antiguo 07/03/2008, 11:44
Avatar de gal_266
gal_266
 
Fecha de Ingreso: septiembre-2006
Ubicación: La ciudad de los palacios
Mensajes: 37
Antigüedad: 20 años, 1 mes
Puntos: 0
Re: problemilla con un formulario...

el codigo del primer formulario es este
Código PHP:
<?php require_once('Connections/dec.php'); ?>
<?php
//MX Widgets3 include
require_once('includes/wdg/WDG.php');

// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_dec = new KT_connection($dec, $database_dec);

//start Trigger_CheckPasswords trigger
//remove this line if you want to edit the code by hand
function Trigger_CheckPasswords(&$tNG) {
  
$myThrowError = new tNG_ThrowError($tNG);
  
$myThrowError->setErrorMsg("Passwords do not match.");
  
$myThrowError->setField("contrasena");
  
$myThrowError->setFieldErrorMsg("The two passwords do not match.");
  return 
$myThrowError->Execute();
}
//end Trigger_CheckPasswords trigger

//start Trigger_WelcomeEmail trigger
//remove this line if you want to edit the code by hand
function Trigger_WelcomeEmail(&$tNG) {
  
$emailObj = new tNG_Email($tNG);
  
$emailObj->setFrom("{KT_defaultSender}");
  
$emailObj->setTo("{email}");
  
$emailObj->setCC("");
  
$emailObj->setBCC("");
  
$emailObj->setSubject("Bienvenido");
  
//FromFile method
  
$emailObj->setContentFile("includes/mailtemplates/welcome.html");
  
$emailObj->setEncoding("ISO-8859-1");
  
$emailObj->setFormat("HTML/Text");
  
$emailObj->setImportance("Normal");
  return 
$emailObj->Execute();
}
//end Trigger_WelcomeEmail trigger

//start Trigger_ActivationEmail trigger
//remove this line if you want to edit the code by hand
function Trigger_ActivationEmail(&$tNG) {
  
$emailObj = new tNG_Email($tNG);
  
$emailObj->setFrom("{KT_defaultSender}");
  
$emailObj->setTo("{email}");
  
$emailObj->setCC("");
  
$emailObj->setBCC("");
  
$emailObj->setSubject("Activación de cuenta");
  
//FromFile method
  
$emailObj->setContentFile("includes/mailtemplates/activate.html");
  
$emailObj->setEncoding("ISO-8859-1");
  
$emailObj->setFormat("HTML/Text");
  
$emailObj->setImportance("Normal");
  return 
$emailObj->Execute();
}
//end Trigger_ActivationEmail trigger

// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("nombre", true, "text", "", "", "", "");
$formValidation->addField("apellidos", true, "text", "", "", "", "");
$formValidation->addField("fecha_nacimiento", true, "date", "date", "", "", "");
$formValidation->addField("sexo", true, "text", "", "", "", "");
$formValidation->addField("pais", true, "text", "", "", "", "");
$formValidation->addField("estado", true, "text", "", "", "", "");
$formValidation->addField("nivel_estudios", true, "numeric", "", "", "", "");
$formValidation->addField("uname", true, "text", "", "", "", "");
$formValidation->addField("contrasena", true, "text", "", "", "", "");
$formValidation->addField("email", true, "text", "email", "", "", "");
$tNGs->prepareValidation($formValidation);
// End trigger

if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

mysql_select_db($database_dec, $dec);
$query_nivest = "SELECT nivel_estudios.estid, nivel_estudios.nivel_estudios FROM nivel_estudios";
$nivest = mysql_query($query_nivest, $dec) or die(mysql_error());
$row_nivest = mysql_fetch_assoc($nivest);
$totalRows_nivest = mysql_num_rows($nivest);

mysql_select_db($database_dec, $dec);
$query_estados = "SELECT estados.estado FROM estados ORDER BY estados.estado";
$estados = mysql_query($query_estados, $dec) or die(mysql_error());
$row_estados = mysql_fetch_assoc($estados);
$totalRows_estados = mysql_num_rows($estados);

// Make an insert transaction instance
$userRegistration = new tNG_insert($conn_dec);
$tNGs->addTransaction($userRegistration);
// Register triggers
$userRegistration->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$userRegistration->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$userRegistration->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");
$userRegistration->registerConditionalTrigger("{POST.contrasena} != {POST.re_contrasena}", "BEFORE", "Trigger_CheckPasswords", 50);
$userRegistration->registerTrigger("AFTER", "Trigger_WelcomeEmail", 40);
$userRegistration->registerTrigger("AFTER", "Trigger_ActivationEmail", 40);
// Add columns
$userRegistration->setTable("usuarios");
$userRegistration->addColumn("nombre", "STRING_TYPE", "POST", "nombre");
$userRegistration->addColumn("apellidos", "STRING_TYPE", "POST", "apellidos");
$userRegistration->addColumn("fecha_nacimiento", "DATE_TYPE", "POST", "fecha_nacimiento");
$userRegistration->addColumn("sexo", "STRING_TYPE", "POST", "sexo");
$userRegistration->addColumn("pais", "STRING_TYPE", "POST", "pais");
$userRegistration->addColumn("estado", "STRING_TYPE", "POST", "estado");
$userRegistration->addColumn("ciudad", "STRING_TYPE", "POST", "ciudad");
$userRegistration->addColumn("profesion", "STRING_TYPE", "POST", "profesion");
$userRegistration->addColumn("nivel_estudios", "NUMERIC_TYPE", "POST", "nivel_estudios");
$userRegistration->addColumn("otros_estudios", "STRING_TYPE", "POST", "otros_estudios");
$userRegistration->addColumn("uname", "STRING_TYPE", "POST", "uname");
$userRegistration->addColumn("contrasena", "STRING_TYPE", "POST", "contrasena");
$userRegistration->addColumn("randomkey", "STRING_TYPE", "POST", "randomkey");
$userRegistration->addColumn("email", "STRING_TYPE", "POST", "email");
$userRegistration->addColumn("nivel", "NUMERIC_TYPE", "POST", "nivel", "1");
$userRegistration->addColumn("activo", "STRING_TYPE", "VALUE", "");
$userRegistration->addColumn("fecha_alta", "DATE_TYPE", "VALUE", "{NOW_DT}");
$userRegistration->setPrimaryKey("uid", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsusuarios = $tNGs->getRecordset("usuarios");
$row_rsusuarios = mysql_fetch_assoc($rsusuarios);
$totalRows_rsusuarios = mysql_num_rows($rsusuarios);
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:wdg="http://www.interaktonline.com/MXWidgets">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
body {
    background-color: #032E61;
}
-->
</style>