Ver Mensaje Individual
  #10 (permalink)  
Antiguo 03/04/2012, 17:17
Avatar de demoche
demoche
 
Fecha de Ingreso: junio-2006
Mensajes: 124
Antigüedad: 17 años, 10 meses
Puntos: 0
Respuesta: Como valida numero de telefono

Probé así :(
Código PHP:
Ver original
  1. <?php
  2. require ("ClassMathGuard.php");
  3. if($_POST)
  4. {
  5. $javascript_enabled = trim($_POST['browser_check']);
  6. $department = trim($_POST['dept']);
  7. $name = trim($_POST['name']);
  8. $email = trim($_POST['email']);
  9. $phno = trim($_POST['phno']);
  10. $subject = trim($_POST['subject']);
  11. $msg = trim($_POST['msg']);
  12. $selfcopy = trim($_POST['selfcopy']);
  13.  
  14.  
  15. //mail settings
  16. $sales_address = "[email protected]";
  17. $support_address = "[email protected]";
  18. $billing_address = "[email protected]";
  19. $headers = "From: ".$email;
  20. $message = "Contact name: $name\nContact Email: $email\nContact Phone: $phno\n\nMessage: $msg";
  21.  
  22. if (MathGuard :: checkResult($_POST['mathguard_answer'], $_POST['mathguard_code'])) {
  23.  
  24.     if ( $department == "sales") $to = $sales_address;
  25.     elseif ( $department == "support") $to = $support_address;
  26.     elseif ( $department == "billing") $to = $billing_address;
  27.  
  28.     if ( $name == "" )
  29.     {
  30.         $result = "Name field is required";
  31.     }
  32.     elseif (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $email))
  33.     {
  34.         $result = "Enter a valid email address";
  35.     }
  36.     elseif(!preg_match("/^(([0-9]{2}-[0-9]{8})|([0-9]{3}-[0-9]{7}))$/", $celno)) //check for a pattern of 91-0123456789 ej: 221-4593367
  37.     {
  38.         $result = "Tipia bien el numero de celu!";
  39.     }
  40.         elseif(!preg_match("/^[0-9]{3}-[0-9]{8}$/", $celno)) //check for a pattern of 91-0123456789 ej: 221-4593367
  41.     {
  42.         $result = "Enter a valid celphone number";
  43.     }
  44.     elseif ( $subject == "" )
  45.     {
  46.         $result = "Subject is required";
  47.     }
  48.     elseif ( strlen($msg) < 10 )
  49.     {
  50.         $result = "Write more than 10 characters";
  51.     }
  52.     else
  53.     {  
  54.        
  55.             mail($to, $subject, $message, $headers);
  56.         if( $selfcopy == "yes" )
  57.             mail($email, $subject, $message, $headers);
  58.         $result = "Your mail has been sent succesfully!";
  59.        
  60.     }
  61. }
  62. else $result = "Bad Answer, Please try again!";
  63.    
  64.     if($javascript_enabled == "true") {
  65.         echo $result;
  66.         die();
  67.     }
  68.  
  69. }
  70. ?>

Que hice mal?
Gracias de nuevo!