Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/09/2011, 12:19
designjs
Usuario no validado
 
Fecha de Ingreso: junio-2011
Ubicación: Colombia
Mensajes: 15
Antigüedad: 12 años, 10 meses
Puntos: 0
Pregunta Problema con Envio de emails

Bueno tengo un problema y quisiera que me ayudaran....bueno ya he desarrollado algo del código pero me he quedado estancado....Tengo un cliente (un pastor) que tiene un formulario de peticiones de necesidades o cosas por la que quieran que ore...........bueno el formulario se llena y lo envia a la pagina donde estan los formularios............hay un boton que dice "orar por esta peticion" le da clic y sale a lado un conteo de veces que la persona recibio oración.......ya todo eso lo tengo listo.............lo que pasa que el quiere que cuando le den clic en "orar por esta peticion" le envié un correo a la persona de que ya están orando................y la verdad que también lo logré pero me envia un correo cada vez que actualizo la página...............la pregunta es ¿Cómo logro enviar el correo solo cuando presionen en "orar por esta petición"......................ahh se me olvidaba cree un input="hidden" para pasar los datos del email que pusieron en el formulario anterior..........

Les pongo parte del script que utilizo:


ESTE ES EL FORMULARIO
Código PHP:
<?php require_once('../../../Connections/peticiones.php'); ?>
<?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;
}
}

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

$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 messages (pray_nombre, pray_apellido, pray_email, pray_telefono, pray_titulo, pray_peticion) VALUES (%s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['pray_nombre'], "text"),
                       
GetSQLValueString($_POST['pray_apellido'], "text"),
                       
GetSQLValueString($_POST['pray_email'], "text"),
                       
GetSQLValueString($_POST['pray_telefono'], "text"),
                       
GetSQLValueString($_POST['pray_titulo'], "text"),
                       
GetSQLValueString($_POST['pray_peticion'], "text"));

  
mysql_select_db($database_peticiones$peticiones);
  
$Result1 mysql_query($insertSQL$peticiones) or die(mysql_error());

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

if (
$_POST['pray_email']) {
$email $_POST['pray_email'];
}
$destinatario "$pray_email"
$asunto "Este mensaje es de prueba"
$cuerpo 
<html> 
<head> 
   <title>Prueba de correo</title> 
</head> 
<body> 
<h1>Hola amigos!</h1> 
<p> 
<b>Bienvenidos a mi correo electrónico de prueba</b>.Este es un mensaje de que pusiste una oracion. 
</p> 
</body> 
</html> 
'


//para el envío en formato HTML 
$headers "MIME-Version: 1.0\r\n"
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"

//dirección del remitente 
$headers .= "From: Tekno Grafik <[email protected]>\r\n"

//dirección de respuesta, si queremos que sea distinta que la del remitente 
$headers .= "Reply-To: [email protected]\r\n"

//ruta del mensaje desde origen a destino 
$headers .= "Return-path: [email protected]\r\n"

//direcciones que recibián copia 
$headers .= "Cc: [email protected]\r\n"

//direcciones que recibirán copia oculta 
$headers .= "Bcc: [email protected],[email protected]\r\n"

mail($destinatario,$asunto,$cuerpo,$headers
?>
ESTE ES EL DE LAS PETICIONES
Código PHP:
<?php require_once('../../../Connections/peticiones.php'); ?>
<?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;
}
}

$maxRows_peticiones_consultas 20;
$pageNum_peticiones_consultas 0;
if (isset(
$_GET['pageNum_peticiones_consultas'])) {
  
$pageNum_peticiones_consultas $_GET['pageNum_peticiones_consultas'];
}
$startRow_peticiones_consultas $pageNum_peticiones_consultas $maxRows_peticiones_consultas;

mysql_select_db($database_peticiones$peticiones);
$query_peticiones_consultas "SELECT * FROM messages ORDER BY mes_id DESC";
$query_limit_peticiones_consultas sprintf("%s LIMIT %d, %d"$query_peticiones_consultas$startRow_peticiones_consultas$maxRows_peticiones_consultas);
$peticiones_consultas mysql_query($query_limit_peticiones_consultas$peticiones) or die(mysql_error());
$row_peticiones_consultas mysql_fetch_assoc($peticiones_consultas);

if (isset(
$_GET['totalRows_peticiones_consultas'])) {
  
$totalRows_peticiones_consultas $_GET['totalRows_peticiones_consultas'];
} else {
  
$all_peticiones_consultas mysql_query($query_peticiones_consultas);
  
$totalRows_peticiones_consultas mysql_num_rows($all_peticiones_consultas);
}
$totalPages_peticiones_consultas ceil($totalRows_peticiones_consultas/$maxRows_peticiones_consultas)-1;

?>
<?php
if ($_POST['conteo_oracion']) {
$email $_POST['conteo_oracion'];
}
$destinatario "$email"
$asunto "Este mensaje es de prueba"
$cuerpo 
<html> 
<head> 
   <title>Prueba de correo</title> 
</head> 
<body> 
<h1>Hola amigos!</h1> 
<p> 
<b>Bienvenidos a mi correo electrónico de prueba</b>.Este es un mensaje de prueba de que alguien ora por ti. 
</p> 
</body> 
</html> 
'


//para el envío en formato HTML 
$headers "MIME-Version: 1.0\r\n"
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"

//dirección del remitente 
$headers .= "From: Tekno Grafik <[email protected]>\r\n"

//dirección de respuesta, si queremos que sea distinta que la del remitente 
$headers .= "Reply-To: [email protected]\r\n"

//ruta del mensaje desde origen a destino 
$headers .= "Return-path: [email protected]\r\n"

//direcciones que recibián copia 
$headers .= "Cc: [email protected]\r\n"

//direcciones que recibirán copia oculta 
$headers .= "Bcc:[email protected],[email protected]\r\n"

mail($destinatario,$asunto,$cuerpo,$headers
?>

Y ESTE ES LA PARTE EN HTML PARA LAS PETICIONES
Código PHP:
<?php do { ?>
<div class="need_panel_titulo_pray"><p> <?php echo $row_peticiones_consultas['pray_titulo']; ?>...</p></div>
<div class="need_panel_pray">
    <div class="need_panel1_peticion">
        <blockquote><p><?php echo $row_peticiones_consultas['pray_peticion']; ?>...</p></blockquote>
    </div><!--final need_panel1-->            
</div><!--final need_panel1-->
<div class="need_panel_datos">
    <!--<div class="need_panel1_peticion_orar"><a href="intersesores_espiritual.php"><p>orar por esta necesidad</p></a></div>-->

    <input type="hidden" name="conteo_oracion"/><div class="need_panel1_peticion_orar"><div class='up'><a href="" class="vote" id="<?php echo $row_peticiones_consultas['mes_id']; ?>" name="up">Clic para orar | &nbsp;<?php echo $row_peticiones_consultas['up']; ?></a></div></div>
    <div class="need_panel1_peticion_cantidad"><p> veces oraron por tí</p></div>
    <div class="need_panel1_peticion_autor"><p>| <?php echo $row_peticiones_consultas['pray_nombre']; ?> <?php echo $row_peticiones_consultas['pray_apellido']; ?></p></div>
    <div class="need_panel1_peticion_fecha"><p>| <?php echo $row_peticiones_consultas['pray_fecha']; ?></p></div>
</div><!--final need_panle_datos-->    
<?php } while ($row_peticiones_consultas mysql_fetch_assoc($peticiones_consultas)); ?>

POR FAVOR ALGUIEN QUE ME AYUDE Y ME DIGA QUE ME FALTA PLEASE