Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/01/2013, 11:14
Nogardlsda
 
Fecha de Ingreso: septiembre-2010
Mensajes: 15
Antigüedad: 13 años, 7 meses
Puntos: 0
Problema con formulario en PHP

Buenas,

Ante todo gracias por vuestro tiempo. Soy bastante novato en esto... me defiendo en HTML pero apenas con PHP y siempre le he temido a los formularios.

Ahora le estoy echando una mano a mis vecinos con una web y me he atascado en el formulario...

Debería de funcionar perfectamente pues venía en la plantilla que compraron y al parecer sólamente había que introducir el email y ya está, pero una vez subido todo al servidor, no funciona.

¿Podríais decirme que falla? Yo no soy capaz de hayarlo... he revisado los manuales de PHP del foro y no he visto el fallo.

ESTE ES EL HTML:
Código:
  <!-- contact form -->
                      <form id="contactform" method="post" action="mailscript.php">
                        
                            <label for="field1">Nombre: *</label>
                            <input type="text" id="field1" value="" name="field1" tabindex="1" class="contact-input" />
                            
                            <label for="field2">Email: *</label>
                            <input type="text" id="field2" value="" name="field2" tabindex="2" class="contact-input" /> 
                            
                            <label for="field3">Web:</label>                
                            <input type="text" id="field3" value="http://" name="field3" tabindex="3" class="contact-input" />
                            
                            <label for="field4">Teléfono:</label>                       
                            <input type="text" id="field4" value="" name="field4" tabindex="4" class="contact-input" />
                                
                            <label for="field5">Asunto: *</label>
                            <input type="text" id="field5" value="" name="field5" tabindex="5" class="contact-input" /> 
                            
                            <label for="field6">Mensaje: *</label>                                      
                            <textarea id="field6" name="field6" tabindex="6" class="contact-textarea"></textarea>
                            
                            <input type="submit" id="submit" value="Enviar" name="submit" tabindex="7" />
                            
                        </form> 
                        
                        <!-- form validation -->
                            
                            <script type="text/javascript">
                            //<![CDATA[
                              var field1    = new LiveValidation('field1', {onlyOnSubmit: false, validMessage: " "});
                              var field2    = new LiveValidation('field2', {onlyOnSubmit: false, validMessage: " "});
                              //var field3    = new LiveValidation('field3', {onlyOnSubmit: false, validMessage: " "});
                             //var field4    = new LiveValidation('field4', {onlyOnSubmit: false, validMessage: " "});
                              var field5    = new LiveValidation('field5', {onlyOnSubmit: false, validMessage: " "});
                              var field6    = new LiveValidation('field6', {onlyOnSubmit: false, validMessage: " "});
                    
                              field1.add( Validate.Presence,{failureMessage: " "});
                              field2.add( Validate.Email,{failureMessage: " "});
                              field2.add( Validate.Presence,{failureMessage: " "});							  
                              //field3.add( Validate.Presence,{failureMessage: " "});
                              //field4.add( Validate.Presence,{failureMessage: " "});							  
                              field5.add( Validate.Presence,{failureMessage: " "});
                              field6.add( Validate.Presence,{failureMessage: " "});
                           //]]>
                          </script>
Y ESTE ES EL CÓDIGO DEL PHP:
Código:
<?php 
   
	$youremail = '[email protected]';//enter your own email here!

	//
	// main form
	//

if(isset($_POST["submit"])){
 
   // Creating the email
   $msg      = "Send by: ".$_POST['field1']."\r\n\r\n";
   $msg     .= "Emailaddress: ".$_POST['field2']."\r\n\r\n";
   $msg     .= "Website: ".$_POST['field3']."\r\n\r\n";
   $msg     .= "Phone: ".$_POST['field4']."\r\n\r\n";
   $msg     .= "Subject: ".$_POST['field5']."\r\n\r\n";
   $msg     .= "Message:\r\n";
   $msg     .= $_POST['field6']."\r\n";
   
   $subject  = "Email from ".$_POST['field1'];
   $headers  = "From: ".$youremail;
   $headers .= "Reply-To: ".$_POST['field1'];
   
// checking for empty fields 
if((strlen($_POST['field1']) > 1 ) || (strlen($_POST['field2']) > 1 ) || (strlen($_POST['field5']) > 1 ) || (strlen($_POST['field6']) > 1 )){
	
		 
    //Sending the email
   $msg = trim(stripslashes($msg));
   
   //Sending the email	
   if (mail($youremail, $subject, $msg, $headers)){ 
   
       // Redirecting to the thank you page
	   header("Location: messagesend.html" );
	   
     }else{

	   // If the mail is not send 
	   header("Location: senderror.html" );
	   
   }
   
	}else{
		
	   // if fields are empty
	   header("Location: senderror2.html" );
	}   
  
}

?>
Si necesitais qeu os cuelgue también el Scritp, decídmelo y os lo cuelgo enseguida.

Gracias.