Foros del Web » Programando para Internet » PHP »

PHP OO Problema con mensaje de PHP y JavaScript

Estas en el tema de Problema con mensaje de PHP y JavaScript en el foro de PHP en Foros del Web. Buenas tarde, vengo haciendo un formulario en PHP y al llenarlo y poner enviar salen dos mensajes. El problema esta en que dentro del PHP ...
  #1 (permalink)  
Antiguo 10/12/2011, 17:04
 
Fecha de Ingreso: enero-2010
Mensajes: 50
Antigüedad: 14 años, 2 meses
Puntos: 0
Información Problema con mensaje de PHP y JavaScript

Buenas tarde, vengo haciendo un formulario en PHP y al llenarlo y poner enviar salen dos mensajes. El problema esta en que dentro del PHP puse que salgan dichos mensajes a través de JavaScript y al salir el segundo mensaje me sale NaN. ¿Cómo puedo solucionarlo?

El código con el que tengo el problema es el siguiente:

Código:
<?php
echo ("<script language='javascript'>
var saludo1='El formulario ha sido enviado correctamente, ';
var saludo2='pronto nos pondremos en contacto con usted.';
alert(saludo1 +\n+ saludo2);
</script>");
}
?>

El código completo es:

Código:
<html>
<head>
<title>Formulario</title>
</head>
<body>
<LINK REL=StyleSheet HREF="estilo.css" TYPE="text/css" MEDIA=screen>
<div align="center"><img src="/img/punta.jpg" width="754" height="122"></div>
<div align="center">
<tr>
<td><a href="index.html" style="text-decoration:none;"><input type="button" name="inicio" value="Inicio" class="menusuperior"></a></td>
<td><a href="envio.php" style="text-decoration:none;"><input type="button" name="formulario" value="Formulario" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
<td><a href="" style="text-decoration:none;"><input type="button" name="" class="menusuperior"></a></td>
</tr>
<div>
<?php
if (!isset($_POST['email'])) {
?>
<br>
<br>
<br>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post" id="formulario" name="miFormulario" onSubmit="alert('A continuación verifique que sus datos estén correctos.'); return true;">
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Nombre y Apellido</b>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td align="center" width="350" height="50">
      <input name="nombre" type="text" value="Escribe tú nombre" class="nombre" onclick="this.value='';"/>&nbsp;&nbsp;-&nbsp;&nbsp;
    </label>
    <label>
       <input name="apellido" type="text" value="Escribe tú apellido" class="apellido" onclick="this.value=''"/>
    </label>
<br>
</td>
</tr>
</table>
<table border="0"align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <center><b>Teléfono</b>
	</label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input name="codigoareaa" type="text" class="campotelefono" value="(0054)(011)">&nbsp;-&nbsp;
	<label>
    </label>
      <input name="telefono" type="text" value=""></center>
    </label>
<br>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <center><b>Teléfono (Uruguay)</b>
</td>
<td align="center" width="350" height="50">
      <input name="codigoareab" type="text" class="campotelefono" value="(00598 53)">&nbsp;-&nbsp;
      <input name="telefonoUy" type="text" value=""></center>
    </label>
<br>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>BBM</b>
    </label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input name="menssenger" type="text" value="BlackBerryMenssenger" onclick="this.value=''"/>
    </label>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Email</b>
	</label>
</td>
<td align="center" width="350" height="50">
	<label>
      <input name="email" type="text" value="@" class="mail">
    </label>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Fecha en Punta</b>
	</label>
</td>
<td align="center" width="350" height="50">
      <input type="text" name="fecha0" value="Día" class="fecha0" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha1" value="Mes" class="fecha1" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha2" value="Año" class="fecha2" onclick="this.value=''"/>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="506" height="50">
<input class="button" type="reset" name="Borrar datos" value="Borrar"> <b>|</b> <input class="button" type="submit" name="Enviar datos" value="Enviar">
</td>
</tr>
<tr>
<td align="center">
<input type="button" onclick="location.replace('index.html');" value="Inicio" class="button" />
</td>
</tr>
</table>
  </form>
<?php
}else{
  $mensaje="Mensaje del formulario de contacto enviado desde: www.retrocomputacion.com.ar";
  $mensaje.= "\nNombre: ".$_POST['nombre'];
  $mensaje.= "\nApellido: ".$_POST['apellido'];
  $mensaje.= "\nTeléfono: ". $_POST['codigoareaa'] . $_POST['telefono'];
  $mensaje.= "\nTeléfono (Uruguay): ". $_POST['codigoareab']. $_POST['telefonoUy'];
  $mensaje.= "\nFecha en Punta: ".$_POST['fecha0']. $_POST['fecha1']. $_POST['fecha2'];
  $mensaje.= "\nEmail: ".$_POST['email'];
  $mensaje.= "\nBBM: ". $_POST['menssenger'];
  $destino= "[email protected]";
  $remitente = $_POST['email'];
  $asunto = "Mensaje enviado por: ".$_POST['nombre']. "\t" .$_POST['apellido'];
  mail($destino,$asunto,$mensaje,"FROM: $remitente");
  echo ("<br><br>");
  echo ("<center><table border='0' align='center' style='margin-top:-0px;'></center>");
  echo ("<tr><td><center><b>Mensaje enviado por:&nbsp;</b></center></td></tr>");
  echo ("</table>");
  echo ("<table border='1' align='center' style='margin-top:-150px;'>");
  echo ("<tr><td><b>Nombre: </b>".$_POST['nombre']."</tr></td><br/>");
  echo ("<tr><td><b>Apellido: </b>".$_POST['apellido']."</tr></td><br/>");
  echo ("<tr><td><b>Teléfono: </b>". $_POST['codigoareaa'] . $_POST['telefono']."</tr></td><br/>");
  echo ("<tr><td><b>Teléfono (Uruguay): </b>". $_POST['codigoareab']. $_POST['telefonoUy']."</tr></td><br/>");
  echo ("<tr><td><b>Fecha en Punta: </b>". $_POST['fecha0']. "<b>/</b>" .$_POST['fecha1']. "<b>/</b>" . $_POST['fecha2']. "</tr></td><br/>");
  echo ("<tr><td><b>Email: </b>".$_POST['email']."</tr></td><br/>");
  echo ("<tr><td><b>BlackBerryMenssenger: </b>". $_POST['menssenger']."</tr></td><br/><br/>");
  echo ("</table>");
  echo ("</br>");
  echo ("<table border='0' align='center'>");
  print'<tr><td><center><input class="button" type="submit" name="volveratras" value="Volver atrás" onClick="history.go(-1);"> | <a href="envio.php" style="text-decoration: none";><input class="button" type="submit" name="Formulario" value="Formulario"></a> | <a href="index.html" style="text-decoration: none";><input class="button" type="submit" name="inicio" value="Inicio"></a></center></tr></td>';
  echo ("</table>");
?>
<?php
echo ("<script language='javascript'>
var saludo1='El formulario ha sido enviado correctamente, ';
var saludo2='pronto nos pondremos en contacto con usted.';
alert(saludo1 +\n+ saludo2);
</script>");
}
?>
</body>
</html>
Desde ya muchas gracias
  #2 (permalink)  
Antiguo 11/12/2011, 00:04
Avatar de truman_truman  
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: Problema con mensaje de PHP y JavaScript

Probá así a ver que pasa:


<?php
echo ("<script language='javascript'>
var saludo1='El formulario ha sido enviado correctamente, \n';
var saludo2='pronto nos pondremos en contacto con usted.';
alert(saludo1 + saludo2);
</script>");
}
?>
__________________
la la la

Etiquetas: formulario, html, javascript
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 03:11.