Comunidad de diseño web y desarrollo en internet

¿Olvidaste tu usuario o clave? «
registrate

Cerrar

error en formulario con php y hmtl

Citar            
MensajeEscrito el 15 May 2012 08:36 am
Hola, tengo un problema con un formulario. Al enviar me da error en el linea 16, que es justo donde se declaran los estilos css. Si quito todo ese cacho de html, no me da error, por lo que entiendo que tengo algo mal en la sintaxis al insertar html.
¿Cómo puedo solucionarlo?
Muchas gracias


Código :

<?php

if(isset($_POST["enviar"])){
   $asunto="email del formulario";
   $msg="nombre:".$_POST['nombre']."\n";
   $msg="apellidos:".$_POST['apellidos']."\n";
   $msg.="email:".$_POST['email']."\n";
   $msg="direccion:".$_POST['direccion']."\n";
   $msg.="telefono:".$_POST['telefono']."\n";
   $msg.="fax:".$_POST['fax']."\n";
   $msg.="comentario:".$_POST['comentario']."\n";
   
   if(@mail("info@kopidenda.com",$asunto,$msg)){//la @ silencia los mensajes de error.
      $error="?><html>
      <head><title>Kopidenda</title>
      <style type="text/css">
         body {background-color:#666;
         font-family:"Lucida Sans Unicode", Arial, Helvetica, sans-serif;
         font-size:10pt;
         color:#090;
         }

#kutxa{ width: 400px;
      height: 70px;
      position:absolute;
       top:50%;
       left: 50%;
       margin-top: -150px;
       margin-left: -180px;
      }
      </style></head>
      
      <body><div id="kutxa">gracias por contactar con kopidenda...</br></br>
      <a href="contacto.html">volver a la web</a>
      </div>
      </body>
         
</html><?php";
   }else{
      $error="problemas tecnicos. Intentalo mas tarde";
   }
}else{
   header('location:presupuesto.php'); //si no se ha enviado el form, para echar de esta pagina y volver al formulario
}



?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>

<?php
   echo $error;



?>
</body>
</html>

Por tzita

12 de clabLevel



 

firefox
Citar            
MensajeEscrito el 15 May 2012 04:51 pm
La forma en la que estás tratando de asignar $error no es válida. No puedes cerrar y abrir los tags PHP en el medio de una asignación.

Lo que debes hacer es usar la asingación HEREDOC así:

Código PHP :

      $error= <<<end;
<html>
      <head><title>Kopidenda</title>
      <style type="text/css">
         body {background-color:#666;
         font-family:"Lucida Sans Unicode", Arial, Helvetica, sans-serif;
         font-size:10pt;
         color:#090;
         }

#kutxa{ width: 400px;
      height: 70px;
      position:absolute;
       top:50%;
       left: 50%;
       margin-top: -150px;
       margin-left: -180px;
      }
      </style></head>
      
      <body><div id="kutxa">gracias por contactar con kopidenda...</br></br>
      <a href="contacto.html">volver a la web</a>
      </div>
      </body>
         
</html>
end;

Por DriverOp

Claber

1945 de clabLevel



 

opera
Citar            
MensajeEscrito el 15 May 2012 04:52 pm
Bueno, el primer end es sin punto y coma. Mi error de dedo...

Por DriverOp

Claber

1945 de clabLevel



 

opera
Citar            
MensajeEscrito el 15 May 2012 06:51 pm
Gracias! Ya voy a probar. La verdad es que ando bastante perdida...

Por tzita

12 de clabLevel



 

firefox
Citar            
MensajeEscrito el 16 May 2012 08:42 am
Ya he probado y perfecto! muchas gracias!

Por tzita

12 de clabLevel



 

firefox

   Página 1 de 1

 

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