Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/04/2017, 13:43
Triby2
 
Fecha de Ingreso: julio-2014
Mensajes: 334
Antigüedad: 9 años, 9 meses
Puntos: 30
Respuesta: Duda de funcion

Bueno, no tiene mucha complicacion, solo ha que seguir el orden y la estructura.

Código PHP:
Ver original
  1. <?php
  2. // The form processor PHP code
  3. function process_si_contact_form()
  4. {
  5.     $userName = @$_POST['userName'];
  6.     $password =  @$_POST['password'];
  7.  
  8.     if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['do'] == 'contact') {
  9.         // if the form has been submitted
  10.  
  11.         foreach($_POST as $key => $value) {
  12.             if (!is_array($key)) {
  13.                 // sanitize the input data
  14.                 if ($key != 'ct_message') $value = strip_tags($value);
  15.                 $_POST[$key] = htmlspecialchars(stripslashes(trim($value)));
  16.             }
  17.         }
  18.  
  19.         $captcha = @$_POST['ct_captcha']; // the user's entry for the captcha code
  20.  
  21.         $errors = array();  // initialize empty error array
  22.  
  23.         // Only try to validate the captcha if the form has no errors
  24.         // This is especially important for ajax calls
  25.         if (sizeof($errors) == 0) {
  26.             require_once dirname(__FILE__) . '/securimage.php';
  27.             $securimage = new Securimage();
  28.  
  29.             if ($securimage->check($captcha) == false) {
  30.                 $errors['captcha_error'] = 'Verifica el resultado del captcha.';
  31.                 //echo '<script language="javascript">alert("Verifica el resultado del captcha.");</script>';
  32.             }
  33.  
  34.             // no errors, send the form
  35.             $return = array('error' => 0, 'message' => $userName);  
  36.         } else {
  37.             $errmsg = 'mensaje ok?';
  38.             foreach($errors as $key => $error) {
  39.                 // set up error messages to display with each field
  40.                 $errmsg .= " - {$error}\n";
  41.             }
  42.             $return = array('error' => 1, 'message' => $errmsg);  
  43.         }
  44.         die(json_encode($return));
  45.     } // POST
  46. } // function process_si_contact_form()
  47.  
  48. ?>

Pero el código que tu compartiste tiene el $_POST de las variables userName y password mal escrito, le falta una "T"