Foros del Web » Programando para Internet » PHP »

Problema enviar formulario php+mysql

Estas en el tema de Problema enviar formulario php+mysql en el foro de PHP en Foros del Web. Buenas, tengo un formulario el cual envía un mail, todo funciona ok menos una cosa. A la hora de enviar el mail, me envia la ...
  #1 (permalink)  
Antiguo 05/05/2014, 12:56
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 9 años, 11 meses
Puntos: 0
Problema enviar formulario php+mysql

Buenas, tengo un formulario el cual envía un mail, todo funciona ok menos una cosa.

A la hora de enviar el mail, me envia la ID del centro en vez de enviarme el nombre del centro.

Os explico un poco como tengo las tablas.

La tabla tblcentro tiene los siguientes campos...

intcentro, strNombre, strLocalidad, refProvincia, strDireccion, strCP, strTelefono, intLibros, fchFecha, strObervaciones....

la tabla tblusuarios tiene los siguientes campos...

intId, strNombre, strApellidos, strEspecialidad, intCentro, strLocalidadCentro, strEmail, intTelefono, strMensaje, intActivo, strPassword....

El caso, es que en el mail me envía intCentro y me envía la ID del centro, pero yo quiero que en vez de eso me envíe el strNombre de la tabla tblcentro de la ID que corresponda.

No se si me he explicado bien...

Vamos, si el la id 1 pertenece al centro Centro de prueba, pues me envia 1 en vez de enviarme Centro de prueba.

Os dejo el código a ver si me podeis ayudar. El código lleva bastante mas, todo lo cual funciona bien, pero en eso me estoy atragantando.

Gracias.

Código:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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_conexion, $conexion);
//$query_DatosCentros = "SELECT * FROM tblcentro ORDER BY tblcentro.refProvincia ASC,  tblcentro.strLocalidad ASC , strNombre ASC";
$query_DatosCentros = "SELECT tblcentro.*,tblprovincias.provincia, tblprovincias.id FROM
tblcentro
Inner Join tblprovincias ON tblcentro.refProvincia = tblprovincias.id ORDER BY tblprovincias.provincia ASC, tblcentro.strLocalidad ASC, tblcentro.strNombre ASC";
$DatosCentros = mysql_query($query_DatosCentros, $conexion) or die(mysql_error());
$row_DatosCentros = mysql_fetch_assoc($DatosCentros);
$totalRows_DatosCentros = mysql_num_rows($DatosCentros);

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formulario")) {
  $insertSQL = sprintf("INSERT INTO tblusuarios (strNombre, strApellidos, strEspecialidad, intCentro,  strEmail, intTelefono, strMensaje, intOrigen) VALUES (%s, %s, %s, %s, %s, %s, %s, 0)",
                       GetSQLValueString($_POST['strNombre'], "text"),
                       GetSQLValueString($_POST['strApellidos'], "text"),
                       GetSQLValueString($_POST['strEspecialidad'], "text"),
                       GetSQLValueString($_POST['intCentro'], "int"),        
                       GetSQLValueString($_POST['strEmail'], "text"),
                       GetSQLValueString($_POST['intTelefono'], "int"),
                       GetSQLValueString($_POST['strMensaje'], "text"));

  mysql_select_db($database_conexion, $conexion);
  $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());

  $insertGoTo = "profesores-registro-ok.php";
  /*if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }*/
  header(sprintf("Location: %s", $insertGoTo));
	$asunto = 'Formulario de Contacto Enviado desde profesores registrados';
	$destinatario = '[email protected]';
    $mensaje = "Hola admin,<br />";
    $mensaje .= "se ha enviado un formulario de contacto desde profesores resgistrados con lo siguientes datos:<br /><br />";    $mensaje .= "- Nombre: ".$_POST['strNombre']."<br />";
    $mensaje .= "- Apellidos: ".$_POST['strApellidos']."<br />";
    $mensaje .= "- Especialidad: ".$_POST['strEspecialidad']."<br />";
    $mensaje .= "- Centro: ".$_POST['intCentro']."<br />";
    $mensaje .= "- Telefono: ".$_POST['intTelefono']."<br />";
    $mensaje .= "- Email: ".$_POST['strEmail']."<br />";
    $mensaje .= "- Mensaje: ".nl2br($_POST['strMensaje'])."<br /><br />";	
	EnviarCorreoHTML($destinatario,$asunto,utf8_decode($mensaje));
}
?>
  #2 (permalink)  
Antiguo 05/05/2014, 13:07
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: Problema enviar formulario php+mysql

PHP es OFF TOPIC en los foros de BBDD.

Movido a Foro de PHP.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #3 (permalink)  
Antiguo 05/05/2014, 13:10
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: Problema enviar formulario php+mysql

Como también era cosa también de la mysql lo habia puesto allí. Sorry.
  #4 (permalink)  
Antiguo 05/05/2014, 13:24
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: Problema enviar formulario php+mysql

Cita:
Iniciado por mortisdj Ver Mensaje
Como también era cosa también de la mysql lo habia puesto allí. Sorry.
El problema planteado es programático, no de SQL. Si no te llega un X dato a la base es porque desde la aplicación no envía el dato.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #5 (permalink)  
Antiguo 05/05/2014, 13:28
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: Problema enviar formulario php+mysql

Ok, de nuevo sorry por ponerlo en donde no tocaba y gracias por la aclaración, :)

Etiquetas: campo, formulario, join, mysql, null, registro, select, sql, tabla, usuarios
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 08:51.