Foros del Web » Programando para Internet » PHP »

Problemas con PHP y iframe en Facebook

Estas en el tema de Problemas con PHP y iframe en Facebook en el foro de PHP en Foros del Web. Hola a tod@s, Os cuento mi problema es el siguiente: estoy haciendo un fan page con html apuntando a los archivos en mi servidor ya ...
  #1 (permalink)  
Antiguo 03/07/2011, 17:35
 
Fecha de Ingreso: mayo-2007
Mensajes: 419
Antigüedad: 16 años, 11 meses
Puntos: 20
Problemas con PHP y iframe en Facebook

Hola a tod@s,

Os cuento mi problema es el siguiente: estoy haciendo un fan page con html apuntando a los archivos en mi servidor ya que facebook no deja alojar archivos, hasta ahi todo bien, el problema realmente me viene al realizar un formulario de contacto tipico donde utilizo tanto textos de tipo radio y cajas de texto y que esa informacion me la envie a una cuenta de correo, como siempre. A principio me dio un poco de problema al usar PHP ya que facebook no te deja utilizar ni el metodo post ni get, la unica forma que te permite utilizarlos es metiendo el codigo de php en otro archivo y apuntas a ese archivo con un iframe (el nuevo fbml de facebook segun entendi). Entonces he creado dos archivos uno donde muestro la parte de fuera del formulario que realmente es el header y footer, en el pongo la etiqueta iframe apuntando al otro archivo, y otro donde esta todo el formulario y su codigo php. Lo he probado en Facebook y parece que sale bien pero el formulario no funciona no manda nada y lo peor es que una vez que le doy al boton me carga toda la pagina dentro del iframe (header y footer incluido).

alguien podria ayudarme a buscar una solucion para que mi formulario funcione y para que no me cargue la web dentro del iframe?

Os dejo abajo el codigo de los archivos:

primero el Sign-up1.php (Es donde sale la parte de fuera del formulario)

Código:
<!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" />
<link rel="stylesheet" type="text/css" href="http://www.xxxxxx.com/social/style/style.css" />
<title>Contact and Sign up to Newsletter</title>

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>

  FB.Canvas.setAutoResize();

</script> 

</head>


<body>
    
    <div class="wraper"><!--start wraper-->

   
        	
        	<div class="header"><!--======start Header-->
        	  
<div id="menu"> <!--======Start Menu--> 

		<ul>
			<li><a href="http://www.xxxxxxxxxxxxxx.com/social/personal-chef.php" title="Personal Chef">Personal Chef</a></li>
			<li><a href="http://www.xxxxxxxxxx.com/social/fine-private-dinning-and-boutique-events.php" title="Private Dinning">Fine Dining</a></li>

	<li><a href="http://www.xxxxxxxxxx.com/social/yacht-provisions.php" title="Yacht Provisions">Yacht Provisions</a></li>
    <li><a href="http://www.xxxxxxxx.com/social/sign-up.php" title="Contact">Contact</a></li>
	<li><a href="#" title="Recipes">Recipes</a>
    <ul>
	<li><a href="http://www.xxxxx.com/social/bbq-free-recipes.php" title="BBQ FREE Recipes">BBQ Recipes</a></li>
	</ul>
   </li> 
</ul></div><!--======finish menu-->
		
			

</div><!--======finish Header--> 

	    
            <!--===============start contenedor-->
            <div class="contenedor">
            
 <br /><br />           
            
            </div> <!--===============end contentenedor-->
       <br />
       
      <iframe src="http://www.xxxxxx.com/social/sign-up2.php" width="100%" height="1260" frameborder="0" scrolling=no></iframe>
      <br /><br />
       
       
       
              
                <!--========start footer==============-->
<div class="footer">
            	<b>Join Us</b>
                <ul class="footerNav">
                	<br /><br />
                    <li><a href="mailto:[email protected]"><img src="http://social/images/btn_mail.png" width="51" height="51" alt="Email Us" /> </a></li>
          <li><a href="http://www.XXXXX.com"><img src="http://social/images/btn_website.png" alt="View our Homepage" /></a></li>
                    <li><a href="http://www.facebook.com/sharer.php?u=http://es-es.facebook.com/XXXXX" title="Share us on Facebook"><img src="http://social/images/btn_facebook.png" /></a></li>
                    <li> <a href="http://twitter.com/#!/XXXX"><img src="http://social/images/btn_twitter.png" alt="Follow us on Twitter" /></a></li>
                    <li><a href="http://es.linkedin.com/XXXX"><img src="http://social/images/btn_linkedin.png" alt="Follow us on Linkedin" /></a></li>
                     <li><a href="http://www.youtube.com/user/xxxx"><img src="http://social/images/btn_youtube.png" alt="View our Youtube Channel" /></a></li>
  </ul><br />
                <span>Call Us Now +34 XXX XXX XXX</span>
</div>  <!--========end footer==============--><!--========end wrap==============-->
 </div>  
<div id="fb-root"></div><br /><br />
<div class="textofooter">

</table>
</div> 
    
</body>
</html>
He puesto los datos de URLs y privados con XXXX asi que no le deis importancia

El segundo archivo lo pongo abajo pq me dice que son mas de 10 mil caracteres y el foro no me lo permite.
  #2 (permalink)  
Antiguo 03/07/2011, 17:35
 
Fecha de Ingreso: mayo-2007
Mensajes: 419
Antigüedad: 16 años, 11 meses
Puntos: 20
Respuesta: Problemas con PHP y iframe en Facebook

Aqui el segundo archivo donde va todo el codigo de php se llama sign-up2.php (el que llamo en el iframe de arriba)

Código:
         
<?php if($_POST){
	
/**** Cambiar aqui ****/
	$para = '[email protected]';
/*********************/
	$asunto = 'New contact from Facebook';
	$mensaje = '';
	foreach($_POST as $key=>$value){
		$vacio = trim($value);
		if($key == 'Email Address'){
			if(empty($vacio)){
				echo 'The email address you introduced is incorrect, please check it';
				$form = 'mal';
			}
			$mail_correcto = 0;
			if ((strlen($value) >= 6) && (substr_count($value,"@") == 1) && (substr($value,0,1) != "@") && (substr($value,strlen($value)-1,1) != "@")){
				if ((!strstr($value,"'")) && (!strstr($value,"\"")) && (!strstr($value,"\\")) && (!strstr($value,"\$")) && (!strstr($value," "))) {
					//miro si tiene caracter .
					if (substr_count($value,".")>= 1){
						//obtengo la terminacion del dominio
						$term_dom = substr(strrchr ($value, '.'),1);
						//compruebo que la terminacion del dominio sea correcta
						if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
							//compruebo que lo de antes del dominio sea correcto
							$antes_dom = substr($value,0,strlen($value) - strlen($term_dom) - 1);
							$caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
							if ($caracter_ult != "@" && $caracter_ult != "."){
								$mail_correcto = 1;
							}
						}
					}
				}
			}
			if($mail_correcto == 0){
				echo 'The email address you introduced is incorrect, please check it';
				$form = 'mal';
			}else{
				$de = $value;
			}
		}else if($key == 'First Name' or $key == 'Last Name'){
			if(empty($vacio)){
				echo 'Please fill our contact form with real details';
				$form = 'mal';
			}
			if(preg_match('/[0-9]/',$value) != 0){
				echo 'Please fill our contact form with real details';
				$form = 'mal';
			}
		}else if($key == 'Current Location'){
			if(!empty($value)){
				if(preg_match('/[0-9]/',$value) != 0){
					echo 'Please fill our contact form with real details';
					$form = 'mal';
				}
			}
		}
		$mensaje .= $key.': '.$value."\n";
	}
	mail($para,$asunto,$mensaje,'From: '.$de);
	echo 'Thank you, your message has been sent!';
}
else if(!$_POST or $form == 'mal'){
?>
<FORM NAME="Submit" Enctype="text/plain" action="http://www.xxxxxx.com/social/sign-up.php" method="post">

<p align="center"><img src="http://www.xxxxxxxx.com/social/images/bravura-logo2.jpg" width="297" height="93" /></p><br>

<div class="textoweb2">Please fill out the fields below to receive our newsletter and promotional offers.</div>
<br><br>
<div class="textoweb3"><strong>(Required fields are bold)</strong></div>

<table width="340" border="0">
  <tr>
    <td><div class="textoweb2"><strong>Email Address*:</strong></div></td>
    <td><br /><input type="text" name="Email Address"><br /><br /></td>
  </tr>
  <tr>
    <td><div class="textoweb2"><strong>First Name*:</strong></div></td>
    <td><br /><input type="text" name="First Name"><br /><br /></td>
  </tr>
  <tr>
    <td><div class="textoweb2"><strong>Last Name*:</strong></div></td>
    <td> <br><input type="text" name="Last Name"><br /><br /></td>
  </tr>
   <tr>
    <td><div class="textoweb2">Current Location:</div></td>
    <td> <br><input type="text" name="Current Location"><br /><br /></td>
  </tr>
</table>

 
 
<br /><br />

<div class="textoweb2">Where did you hear about us? </div><br />
<div id="signform1"> <!--start signform1 -->
<table width="240" border="0" align="right">
  <tr>
    <td width="32"><input type="radio" name="marketing" value="Facebook" checked>
    <td width="193">Facebook</td>
   </tr>
  <tr>
      <td><input type="radio" name="marketing" value="Twitter"> <td>Twitter</td>
  </tr>
  <tr>
    <td><input type="radio" name="marketing" value="Search Engine"><td>Search Engine</td>
    </tr>
  <tr>
     <td><input type="radio" name="marketing" value="Newspaper or Magazine"><td> 
     Newspaper or Magazine</td>
  </tr>
  <tr>
      <td><input type="radio" name="marketing" value="From a Friend"> <td>From a Friend</td>

</tr>
 <tr>
      <td>&nbsp;</td>
</tr>
</table>
</div><!--end signform1 -->  





<br />
<table width="302" border="0" align="right">
   <tr>
    <td width="302" height="126">&nbsp;</td>
   </tr>
   <tr>
    <td>&nbsp;</td>
   </tr>
   <tr>
    <td></td>
   </tr>
  <tr></table>
  <br><br><br><br><br><br><br><br><br>
  <table width="400" border="0">
  <tr>

    <td> <div class="textoweb2"><br>Which service would most interest you?</div></td>
  </tr>
</table>

 
  <table width="277" border="0" align="right">
   <tr>
     <td width="10">&nbsp;</td>
     <td width="20">&nbsp;</td>
  <td width="182">&nbsp;</td>
  </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="radio" name="service" value="Personal Chef" checked></td><td width="182">Personal Chef</td>
    <td width="47"></td>
       
   </tr>
  <tr>
    <td>    
    <td><input type="radio" name="service" value="Private & Boutique Dining"><td> Private & Boutique Dining   
      <td></td>
  </tr>
  <tr>
    <td>    
    <td>    <input type="radio" name="service" value="Fit - Food Packages"> 
    <td>Fit - Food Packages</td>
    <td>
    </tr>
  <tr>
    <td>    
    <td>  <input type="radio" name="service" value="Corporate Entertaining"> <td>Corporate Entertaining</td>  
     <td>
  </tr>
  <tr>
    <td>    
    <td> <input type="radio" name="service" value="Cookery Classes"><td> Cookery Classes</td>   
      <td>

</tr>
 <tr>
   <td>   
   <td>  <input type="radio" name="service" value="Yacht Provisions"> <td>Yacht Provisions</td> 
      <td>

</tr>
 <tr>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
      <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
      <td><input type="submit" value="Submit"></td>
</tr>

</table>

</FORM>

<?php
}
?>

</div>

Avisarme con lo que sea, ya que facebook y su iframe me tienen super desesperada.

mil besos y gracias
  #3 (permalink)  
Antiguo 04/07/2011, 03:46
 
Fecha de Ingreso: mayo-2007
Mensajes: 419
Antigüedad: 16 años, 11 meses
Puntos: 20
Respuesta: Problemas con PHP y iframe en Facebook

Alguien entiende lo que hago mal?
  #4 (permalink)  
Antiguo 05/07/2011, 16:52
 
Fecha de Ingreso: mayo-2007
Mensajes: 419
Antigüedad: 16 años, 11 meses
Puntos: 20
Respuesta: Problemas con PHP y iframe en Facebook

Ya lo consegui, el iframe andaba perfectamente tenia mal el codigo php, realmente me acabo de dar cuenta que PHP es case sensitive, ya que tenia puesto lo siguiente:

<FORM NAME="Submit" action="" method="post"> y la forma correcta es la siguiente:
<form name="Submit" action="" method="post">


menuda tonteria :D pero bueno me tenia como loca, queria agradecer igualmente a todos por la ayuda y dejo la solucion en caso que le pase a alguien.

mil besos y gracias

Etiquetas: facebook, iframe
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 16:50.