function displayForm($errorMessages, $missingFields, $member) { displayPageHeader("Login to the twitteresque members' area"); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } else { ?> <p>To access the members' area, pleas enter your username then click Login.</p> <?php } ?> <form action="login.php" method="post" style="margin-bottom: 50px;"> <div style="width: 30em;"> <input type="hidden" name="action" value="login" /> <label for="username"<?php validateField("username", $missingFields); ?> >Username</label> <input type="text" name="username" id="username" value="<?php echo $member->getValueEncoded("username"); ?> " /> <div style="clear: both;"> <input type="submit" name="submitButton" id="submitButton" value="Login" /> </div> </div> </form> <?php displayPageFooter(); }
function displayForm($camposPendientes) { if ($camposPendientes) { $error = '<p class="error">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete correctamente los campos remarcados de abajo y haga clic en Enviar para volver a enviar el formulario.</p>'; } else { $error = '<p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p>'; } $resultados = array("error" => $error, "scriptUrl" => "index.php", "validacionNombreUsuario" => validateField("nombreUsuario", $camposPendientes), "valorNombreUsuario" => setValue("nombreUsuario"), "validacionApellidos" => validateField("apellidos", $camposPendientes), "valorApellidos" => setValue("apellidos"), "tipoMusicaRock" => setSelected("tipoMusica", "Rock"), "tipoMusicaPop" => setSelected("tipoMusica", "Pop"), "tipoMusicaRegee" => setSelected("tipoMusica", "Regee"), "tipoMusicaClasica" => setSelected("tipoMusica", "Clasica"), "tipoLibrosNovelaNegra" => setChecked("tipoLibros", "Novela Negra"), "tipoLibrosCienciaFiccion" => setChecked("tipoLibros", "Ciencia Ficcion"), "tipoLibrosFantasia" => setChecked("tipoLibros", "Fantasia")); $plantilla = "plantillas/encuestaForm.html"; $formulario = vista($resultados, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm($camposPendientes) { if ($camposPendientes) { $error = '<p class="error">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete correctamente los campos remarcados de abajo y haga clic en Enviar para volver a enviar el formulario.</p>'; } else { $error = '<p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p>'; } $datos = array("error" => $error, "scriptUrl" => "index.php", "validacionNombre" => validateField("nombre", $camposPendientes), "valorNombre" => setValue("nombre"), "valorComentario" => setValue("comentario"), "validacionClave" => validateField("clave", $camposPendientes), "valorClave" => setValue("clave"), "precio" => array("mas 14k" => setSelectedParaUno("precio", "mas 14k"), "14k" => setSelectedParaUno("precio", "14k"), "menos 14k" => setSelectedParaUno("precio", "menos 14k")), "color" => array("rojo" => setChecked1("color", "rojo"), "verde" => setChecked1("color", "verde"), "azul" => setChecked1("color", "azul")), "extras" => array("aireAcondicionado" => setChecked2("extras", "aireAcondicionado"), "Yantas" => setChecked2("extras", "Yantas"), "Tapiceria" => setChecked2("extras", "Tapiceria"))); $plantilla = "plantillas/encuestaForm.html"; $formulario = vista($datos, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm1($camposPendientes = array(), $camposErroneos = array(), $mensajeErrorImagen = "correcto") { if ($camposPendientes || $camposErroneos || $mensajeErrorImagen != "correcto") { $error = '<p class="error1">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete correctamente los campos remarcados de abajo y haga clic en Enviar para volver a enviar el formulario.</p>'; } else { $error = '<p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p>'; } if (count($camposPendientes) > 0) { $error .= "<p class='error2'>Faltan por rellenar campos en el formulario:"; foreach ($camposPendientes as $campo) { $error .= $campo . ", "; } $error = preg_replace("/, \$/", "", $error); $error .= "</p>"; } if (count($camposErroneos) > 0) { $error .= "<p class='error1'>Hay campos mal rellenados en el formulario:"; foreach ($camposErroneos as $campo) { $error .= $campo . ", "; } $error = preg_replace("/, \$/", "", $error); $error .= "</p>"; } if ($mensajeErrorImagen != "correcto") { $error .= "<p class='error3'>{$mensajeErrorImagen}</p>"; } $ciudades = array("Roma", "Paris", "Nueva York", "Londres", "Berlin", "Atenas"); $medios = array("correoPostal", "email"); $ocultosCiudades = ""; foreach ($ciudades as $ciudad) { $ocultosCiudades .= '<input type="hidden" name="ciudades[]" value="' . setValue("ciudades", $ciudad) . "\"/>\n"; } $ocultosMedios = ""; foreach ($medios as $medio) { $ocultosMedios .= '<input type="hidden" name="medios[]" value="' . setValue("medios", $medio) . "\"/>\n"; } $datos = array("error" => $error, "scriptUrl" => "index.php", "ocultosCiudades" => $ocultosCiudades, "ocultosMedios" => $ocultosMedios, "validacionNombre" => validateField("nombre", $camposPendientes, $camposErroneos), "valorNombre" => setValue("nombre"), "validacionApellidos" => validateField("apellidos", $camposPendientes, $camposErroneos), "valorApellidos" => setValue("apellidos"), "validacionDireccion" => validateField("direccion", $camposPendientes, $camposErroneos), "valorDireccion" => setValue("direccion"), "validacionTelefono" => validateField("telefono", $camposPendientes, $camposErroneos), "valorTelefono" => setValue("telefono"), "validacionEmail" => validateField("email", $camposPendientes, $camposErroneos), "valorEmail" => setValue("email"), "validacionFoto" => validateField("foto1", $camposPendientes, $camposErroneos, $mensajeErrorImagen)); $plantilla = "plantillas/formulario.html"; $formulario = vista($datos, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm($errorMessages, $missingFields, $cliente) { displayPageHeader("Logueate para poder realizar pedidos", true); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } else { ?> <p>Para acceder a algunas paginas debes estar registrado. Por favor, logueate o <a href="registro.php">registrate</a></p> <?php } ?> <form class="form-horizontal" role="form" action="login.php" method="post"> <div class="form-group"> <input type="hidden" name="action" value="login" /> <label for="email"<?php validateField("email", $missingFields); ?> class="col-sm-2 control-label">Email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" name="email" value="<?php echo $cliente->getValueEncoded("email"); ?> "> </div> </div> <div class="form-group"> <label for="pass" <?php if ($missingFields) { } ?> class="col-sm-2 control-label">Password</label> <div class="col-sm-10"> <input type="password" class="form-control" id="pass" name="pass"/> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" name="submitButton" id="submitButton" class="btn btn-default" value="login">Iniciar sesión</button> </div> </div> </form> </div> </div> </div> </div> <?php displayPageFooter(); }
function displaypaso1($camposPendientes, $camposErroneos, $mensajeFoto) { if ($camposPendientes or $camposErroneos or $mensajeFoto != "correcto") { $error = ""; if ($camposPendientes) { $error = '<p class="error1">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete los campos en negrita de abajo y haga clic en Enviar para volver a enviar el formulario.</p>'; } if ($camposErroneos) { $error .= '<p class="error2">Hubo algunos problemas con el formulario que usted presentó. Por favor, introduzca valores adecuados en los campos numéricos.</p>'; } if ($mensajeFoto != 'correcto') { $error .= '<p class="error3">Hubo algunos problemas con la foto. ' . $mensajeFoto . '</p>'; } } else { $error = '<p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p>'; } $ciudades = array('Roma', 'Paris', 'Nueva York', 'Londres', 'Berlin', 'Atenas'); $ocultosInformacion = ""; $ocultosCiudades = ""; foreach ($ciudades as $valor) { $valorCampo = setValue2("ciudades", $valor); $ocultosCiudades .= '<input type="hidden" name="ciudades[]" value="' . $valorCampo . '">'; } $informacion = array('Correo Postal', 'Email'); foreach ($informacion as $valor) { $valorCampo = setValue2("informacion", $valor); $ocultosInformacion .= '<input type="hidden" name="informacion[]" value="' . $valorCampo . '">'; } $datos = array("error" => $error, "ocultosCiudades" => $ocultosCiudades, "ocultosInformacion" => $ocultosInformacion, "validacionNombre" => validateField("nombre", $camposPendientes, $camposErroneos), "nombre" => setValue("nombre"), "validacionApellidos" => validateField("apellidos", $camposPendientes, $camposErroneos), "apellidos" => setValue("apellidos"), "validacionDireccion" => validateField("direccion", $camposPendientes, $camposErroneos), "direccion" => setValue("direccion"), "validacionTelefono" => validateField("telefono", $camposPendientes, $camposErroneos), "telefono" => setValue("telefono"), "email" => setValue("email"), "validacionEmail" => validateField("email", $camposPendientes, $camposErroneos), "validacionFoto" => validateField("foto", $camposPendientes, $camposErroneos)); $plantilla = "plantillas/paso1.html"; $formulario = vista($datos, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm($errorMessages, $missingFields, $member) { displayPageHeader("Sign up for the book club!"); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } else { ?> <p>Thanks for choosing to join our book club.</p> <p>To register, please fill in your details below and click Send Details.</p> <p>Fields marked with an asterisk (*) are required.</p> <?php } ?> <form action="register.php" method="post" style="margin-bottom: 50px;"> <div style="width: 30em;"> <input type="hidden" name="action" value="register" /> <label for="username"<?php validateField("username", $missingFields); ?> >Choose a username *</label> <input type="text" name="username" id="username" value="<?php echo $member->getValueEncoded("username"); ?> " /> <label for="password1"<?php if ($missingFields) { echo ' class="error"'; } ?> >Choose a password *</label> <input type="password" name="password1" id="password1" value="" /> <label for="password2"<?php if ($missingFields) { echo ' class="error"'; } ?> >Retype password *</label> <input type="password" name="password2" id="password2" value="" /> <label for="emailAddress"<?php validateField("emailAddress", $missingFields); ?> >Email address *</label> <input type="text" name="emailAddress" id="emailAddress" value="<?php echo $member->getValueEncoded("emailAddress"); ?> " /> <label for="firstName"<?php validateField("firstName", $missingFields); ?> >First name *</label> <input type="text" name="firstName" id="firstName" value="<?php echo $member->getValueEncoded("firstName"); ?> " /> <label for="lastName"<?php validateField("lastName", $missingFields); ?> >Last name *</label> <input type="text" name="lastName" id="lastName" value="<?php echo $member->getValueEncoded("lastName"); ?> " /> <label<?php validateField("gender", $missingFields); ?> >Your gender: *</label> <label for="genderMale">Male</label> <input type="radio" name="gender" id="genderMale" value="m"<?php setChecked($member, "gender", "m"); ?> /> <label for="genderFemale">Female</label> <input type="radio" name="gender" id="genderFemale" value="f"<?php setChecked($member, "gender", "f"); ?> /> <label for="favoriteGenre">What's your favorite genre?</label> <select name="favoriteGenre" id="favoriteGenre" size="1"> <?php foreach ($member->getGenres() as $value => $label) { ?> <option value="<?php echo $value; ?> "<?php setSelected($member, "favoriteGenre", $value); ?> ><?php echo $label; ?> </option> <?php } ?> </select> <label for="otherInterests">What are your other interests?</label> <textarea name="otherInterests" id="otherInterests" rows="4" cols="50"><?php echo $member->getValueEncoded("otherInterests"); ?> </textarea> <div style="clear: both;"> <input type="submit" name="submitButton" id="submitButton" value="Send Details" /> <input type="reset" name="resetButton" id="resetButton" value="Reset Form" style="margin-right: 20px;" /> </div> </div> </form> <?php displayPageFooter(); }
function displayPaso1($camposPendientes, $mensaje) { if ($camposPendientes || $mensaje == "error") { if ($camposPendientes) { echo "<p class='error'>Hubo problemas en tu formulario</p>"; } if ($mensaje = "error") { echo "<p class='error'>Hubo problemas en tu foto</p>"; } } else { echo "<p> Rellene el siguiente formulario</p>"; } cabecera(); ?> <h1>Solicitud de informacion: paso 1</h1> <form action="" method="post" enctype="multipart/form-data"> <div style="width: 30em;"> <?php $arrayCiudades = array("Roma", "Paris", "Nueva York", "Londres", "Berlin", "Atenas"); foreach ($arrayCiudades as $value) { ?> <input type="hidden" name="ciudades[]" value="<?php setValue2("ciudades", $value); ?> "> <?php } ?> <label for="nombre" <?php validateField("nombre", $camposPendientes); ?> >Nombre</label> <input type="text" name="nombre" id="nombre" value="<?php setValue("nombre"); ?> "> <label for="apellidos" <?php validateField("apellidos", $camposPendientes); ?> >Apellidos</label> <input type="text" name="apellidos" id="apellidos" value="<?php setValue("apellidos"); ?> "> <label for="direccion" <?php validateField("direccion", $camposPendientes); ?> >Direccion</label> <input type="text" name="direccion" id="direccion" value="<?php setValue("direccion"); ?> "><br> <label for="telefono" <?php validateField("telefono", $camposPendientes); ?> >Telefono</label> <input type="text" name="telefono" id="telefono" value="<?php setValue("telefono"); ?> "> <input type='file' name='foto' id='foto'><br> <br><br><br><br> <div style="clear: both;"> <input type="submit" name="next1" id="nextButton" value="Next >" > </div> </div> </form> </body> </html> <?php pie(); }
function eForm($modx, $params) { global $_lang; global $debugText; global $formats, $fields, $efPostBack; $fields = array(); //reset fields array - needed in case of multiple forms // define some variables used as array index $_dfnMaxlength = 6; extract($params, EXTR_SKIP); // extract params into variables #include default language file include_once $snipPath . "lang/english.inc.php"; #include other language file if set. $form_language = isset($language) ? $language : $modx->config['manager_language']; if ($form_language != "english" && $form_language != '') { if (file_exists("{$snipPath}lang/{$form_language}.inc.php")) { include_once "{$snipPath}lang/{$form_language}.inc.php"; } else { if ($isDebug) { $debugText .= "<strong>Language file '{$form_language}.inc.php' not found!</strong><br />"; } } //always in english! } # add debug warning - moved again... if ($isDebug) { $debugText .= $_lang['ef_debug_warning']; } # check for valid form key - moved to below fetching form template to allow id coming from form template $nomail = $noemail; //adjust variable name confusion # activate nomail if missing $to if (!$to) { $nomail = 1; } # load templates if ($tpl == $modx->documentIdentifier) { return $_lang['ef_is_own_id'] . "'{$tpl}'"; } //required if (empty($tpl)) { $formid = "eform"; $tpl = get_default_tpl(); } elseif ($tmp = efLoadTemplate($tpl)) { $tpl = $tmp; } else { return $_lang['ef_no_doc'] . " '{$tpl}'"; } # check for valid form key if ($formid == '') { $formid = 'eform'; } // try to get formid from <form> tag id preg_match('/<form[^>]*?id=[\'"]([^\'"]*?)[\'"]/i', $tpl, $matches); $form_id = isset($matches[1]) ? $matches[1] : ''; //check for <input type='hidden name='formid'...> if (!preg_match('/<input[^>]*?name=[\'"]formid[\'"]/i', $tpl)) { //insert hidden formid field $tpl = str_replace('</form>', "<input type=\"hidden\" name=\"formid\" value=\"{$formid}\" /></form>", $tpl); } $validFormId = isset($_POST['formid']) && $formid == $_POST['formid'] ? 1 : 0; # check if postback mode $efPostBack = $validFormId && count($_POST) > 0 ? true : false; //retain old variable? if ($efPostBack) { if (empty($report)) { $report = get_default_report(); } else { $report = ($tmp = efLoadTemplate($report)) !== false ? $tmp : $_lang['ef_no_doc'] . " '{$report}'"; } if ($thankyou) { $thankyou = ($tmp = efLoadTemplate($thankyou)) !== false ? $tmp : $_lang['ef_no_doc'] . " '{$thankyou}'"; } if ($autotext) { $autotext = ($tmp = efLoadTemplate($autotext)) !== false ? $tmp : $_lang['ef_no_doc'] . " '{$autotext}'"; } } //these will be added to the HEAD section of the document when the form is displayed! if ($cssStyle) { $cssStyle = strpos($cssStyle, ',') && strpos($cssStyle, '<style') === false ? explode(',', $cssStyle) : array($cssStyle); foreach ($cssStyle as $tmp) { $startupSource[] = array($tmp, 'css'); } } if ($jScript) { $jScript = strpos($jScript, ',') && strpos($jScript, '<script') === false ? explode(',', $jScript) : array($jScript); foreach ($jScript as $tmp) { $startupSource[] = array($tmp, 'javascript'); } } #New in 1.4.4 - run snippet to include 'event' functions if (strlen($runSnippet) > 0) { $modx->runSnippet($runSnippet, array('formid' => $formid)); //Sadly we cannot know if the snippet fails or if it exists as modx->runsnippet's return value //is ambiguous } # invoke onBeforeFormParse event set by another script if ($eFormOnBeforeFormParse) { if ($isDebug && !function_exists($eFormOnBeforeFormParse)) { $fields['debug'] .= "eFormOnBeforeFormParse event: Could not find the function " . $eFormOnBeforeFormParse; } else { $templates = array('tpl' => $tpl, 'report' => $report, 'thankyou' => $thankyou, 'autotext' => $autotext); if ($eFormOnBeforeFormParse($fields, $templates) === false) { return ""; } elseif (is_array($templates)) { extract($templates); } // extract back into original variables } } # parse form for formats and generate placeholders $tpl = eFormParseTemplate($tpl, $isDebug); if ($efPostBack) { foreach ($formats as $k => $discard) { if (!isset($fields[$k])) { $fields[$k] = ""; } } // store dummy value inside $fields $disclaimer = ($tmp = efLoadTemplate($disclaimer)) !== false ? $tmp : ''; //error message containers $vMsg = $rMsg = $rClass = array(); # get user post back data foreach ($_POST as $name => $value) { if (is_array($value)) { //remove empty values $fields[$name] = array_filter($value, create_function('$v', 'return (!empty($v));')); } else { $value = htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']); if ($allowhtml || $formats[$name][2] == 'html') { $fields[$name] = stripslashes($value); } else { $fields[$name] = strip_tags(stripslashes($value)); } } } # get uploaded files foreach ($_FILES as $name => $value) { $fields[$name] = $value; } # check vericode if ($vericode) { //add support for captcha code - thanks to Djamoer $code = $_SESSION['veriword'] ? $_SESSION['veriword'] : $_SESSION['eForm.VeriCode']; if ($fields['vericode'] != $code) { $vMsg[count($vMsg)] = $_lang['ef_failed_vericode']; $rClass['vericode'] = $invalidClass; //added in 1.4.4 } } # sanitize the values with slashes stripped to avoid remote execution of Snippets modx_sanitize_gpc($fields); # validate fields foreach ($fields as $name => $value) { $fld = isset($formats[$name]) ? $formats[$name] : ''; if ($fld) { $desc = $fld[1]; $datatype = $fld[2]; $isRequired = $fld[3]; if ($isRequired == 1 && $value == "" && $datatype != "file") { $rMsg[count($rMsg)] = "{$desc}"; $rClass[$name] = $requiredClass; } elseif (!empty($fld[5]) && $value != "" && $datatype != "file") { $value = validateField($value, $fld, $vMsg, $isDebug); if ($value === false) { $rClass[$name] = $invalidClass; } elseif ($value !== true) { $fields[$name] = $value; } //replace value. } else { //value check switch ($datatype) { case "integer": case "float": if (strlen($value) > 0 && !is_numeric($value)) { $vMsg[count($vMsg)] = $desc . $_lang["ef_invalid_number"]; $rClass[$name] = $invalidClass; } break; case "date": if (strlen($value) == 0) { break; } //corrected by xwisdom for php version differences $rt = strtotime($value); //php 5.1.0+ returns false while < 5.1.0 returns -1 if ($rt === false || $rt === -1) { $vMsg[count($vMsg)] = $desc . $_lang["ef_invalid_date"]; $rClass[$name] = $invalidClass; } break; case "email": //stricter email validation - udated to allow + in local name part if (strlen($value) > 0 && !preg_match('/^(?:[a-z0-9+_-]+?\\.)*?[a-z0-9_+-]+?@(?:[a-z0-9_-]+?\\.)*?[a-z0-9_-]+?\\.[a-z0-9]{2,5}$/i', $value)) { $vMsg[count($vMsg)] = isset($formats[$name][4]) ? $formats[$name][4] : $desc . $_lang["ef_invalid_email"]; $rClass[$name] = $invalidClass; } break; case "file": if ($_FILES[$name]['error'] == 1 || $_FILES[$name]['error'] == 2) { $vMsg[count($vMsg)] = $desc . $_lang['ef_upload_exceeded']; $rClass[$name] = $invalidClass; } elseif ($isRequired == 1 && ($_FILES[$name] && $_FILES[$name]['type'] == '')) { $rMsg[count($rMsg)] = $desc; $rClass[$name] = $requiredClass; } elseif ($_FILES[$name]['tmp_name']) { if (substr($fld[5], 0, 5) != "#LIST" || validateField($_FILES[$name]['name'], $fld, $vMsg, $isDebug)) { $attachments[count($attachments)] = $_FILES[$name]['tmp_name']; } else { $rClass[$name] = $invalidClass; } } break; case "html": case "checkbox": case "string": default: break; } } //end required test } } // Changed in 1.4.4.5 - now expects 4 parameters if ($eFormOnValidate) { if ($isDebug && !function_exists($eFormOnValidate)) { $fields['debug'] .= "eformOnValidate event: Could not find the function " . $eFormOnValidate; } else { if ($eFormOnValidate($fields, $vMsg, $rMsg, $rClass) === false) { return; } } } if (count($vMsg) > 0 || count($rMsg) > 0) { //New in 1.4.2 - classes are set in labels and form elements for invalid fields foreach ($rClass as $n => $class) { $fields[$n . '_class'] = $fields[$n . '_class'] ? $fields[$n . '_class'] . ' ' . $class : $class; $fields[$n . '_vClass'] = isset($fields[$n . '_vClass']) ? $fields[$n . '_vClass'] . ' ' . $class : $class; //work around for checkboxes if (isset($formats[$n][6])) { //have separate id's for check and option tags - set classes as well foreach (explode(',', $formats[$n][6]) as $id) { $fields[$id . '_vClass'] = $fields[$id . '_vClass'] ? $fields[$id . '_vClass'] . ' ' . $class : $class; } } } //add debugging info to fields array if ($isDebug) { ksort($fields); if ($isDebug > 1) { $debugText .= "<br /><strong>Formats array:</strong><pre>" . var_export($formats, true) . '</pre>'; $debugText .= "<br /><strong>Fields array:</strong><pre>" . var_export($fields, true) . '</pre>'; $debugText .= "<br /><strong>Classes parsed :</strong><pre>" . var_export($rClass, true) . "</pre>"; } $debugText .= "<br /><strong>eForm configuration:</strong><pre>\n" . var_export($params, true) . '</pre>'; $fields['debug'] = $debugText; } #set validation message $tmp = count($rMsg) > 0 ? str_replace("{fields}", implode(", ", $rMsg), $_lang['ef_required_message']) : ""; $tmp .= implode("<br />", $vMsg); if (!strstr($tpl, '[+validationmessage+]')) { $modx->setPlaceholder('validationmessage', str_replace('[+ef_wrapper+]', $tmp, $_lang['ef_validation_message'])); } else { if (!isset($fields['validationmessage'])) { $fields['validationmessage'] = ''; } $fields['validationmessage'] .= str_replace('[+ef_wrapper+]', $tmp, $_lang['ef_validation_message']); } } else { # format report fields foreach ($fields as $name => $value) { $fld = $formats[$name]; if ($fld) { $datatype = $fld[2]; switch ($datatype) { case "integer": $value = number_format($value); break; case "float": $localeInfo = localeconv(); $th_sep = empty($_lang['ef_thousands_separator']) ? $localeInfo['thousands_sep'] : $_lang['ef_thousands_separator']; $dec_point = $localeInfo['decimal_point']; $debugText .= 'Locale<pre>' . var_export($localeInfo, true) . '</pre>'; $value = number_format($value, 2, $dec_point, $th_sep); break; case "date": $format_string = isset($_lang['ef_date_format']) ? $_lang['ef_date_format'] : '%d-%b-%Y %H:%M:%S'; $value = $value ? strftime($format_string, strtotime($value)) : ""; $value = str_replace("00:00:00", "", $value); // remove trailing zero time values break; case "html": // convert \n to <br /> if (!$sendAsText) { $value = preg_replace('#(\\n<br[ /]*?>|<br[ /]*?>\\n|\\n)#i', '<br />', $value); } break; case "file": // set file name if ($value['type'] != "" && $value['type'] != "") { $value = $value["name"]; $patharray = explode(strpos($value, "/") === false ? "\\" : "/", $value); $value = $patharray[count($patharray) - 1]; } else { $value = ""; } break; } $fields[$name] = $value; } } # set postdate $fields['postdate'] = strftime($modx->toDateFormat(null, 'formatOnly') . " %H:%M:%S", time()); //check against email injection and replace suspect content if (hasMailHeaders($fields)) { //send email to webmaster?? if ($reportAbuse) { //set in snippet configuration tab $body = $_lang['ef_mail_abuse_message']; $body .= "<table>"; foreach ($fields as $key => $value) { $body .= "<tr><td>{$key}</td><td><pre>{$value}</pre></td></tr>"; } $body .= "</table>"; include_once $modx->config['base_path'] . 'manager/includes/controls/modxmailer.inc.php'; $mail = new MODxMailer(); # send abuse alert $mail->IsHTML($isHtml); $mail->From = $modx->config['emailsender']; $mail->FromName = $modx->config['site_name']; $mail->Subject = $_lang['ef_mail_abuse_subject']; $mail->Body = $body; AddAddressToMailer($mail, "to", $modx->config['emailsender']); $mail->Send(); //ignore mail errors in this case } //return empty form with error message //register css and/or javascript if (isset($startupSource)) { efRegisterStartupBlock($startupSource); } return formMerge($tpl, array('validationmessage' => $_lang['ef_mail_abuse_error'])); } # added in 1.4.2 - Limit the time between form submissions if ($submitLimit > 0) { if (time() < $submitLimit + $_SESSION[$formid . '_limit']) { return formMerge($_lang['ef_submit_time_limit'], $fields); } else { unset($_SESSION[$formid . '_limit'], $_SESSION[$formid . '_hash']); } //time expired } # invoke OnBeforeMailSent event set by another script if ($eFormOnBeforeMailSent) { if ($isDebug && !function_exists($eFormOnBeforeMailSent)) { $fields['debug'] .= "eFormOnBeforeMailSent event: Could not find the function " . $eFormOnBeforeMailSent; } elseif ($eFormOnBeforeMailSent($fields) === false) { if (isset($fields['validationmessage']) && !empty($fields['validationmessage'])) { //register css and/or javascript if (isset($startupSource)) { efRegisterStartupBlock($startupSource); } return formMerge($tpl, $fields); } else { return; } } } if ($protectSubmit) { $hash = ''; # create a hash of key data if (!is_numeric($protectSubmit)) { //supplied field names $protectSubmit = strpos($protectSubmit, ',') ? explode(',', $protectSubmit) : array($protectSubmit); foreach ($protectSubmit as $fld) { $hash .= isset($fields[$fld]) ? $fields[$fld] : ''; } } else { foreach ($formats as $fld) { $hash .= $fld[3] == 1 ? $fields[$fld[0]] : ''; } } if ($hash) { $hash = md5($hash); } if ($isDebug) { $debugText .= "<strong>SESSION HASH</strong>:" . $_SESSION[$formid . '_hash'] . "<br />" . "<b>FORM HASH</b>:" . $hash . "<br />"; } # check if already succesfully submitted with same data if (isset($_SESSION[$formid . '_hash']) && $_SESSION[$formid . '_hash'] == $hash && $hash != '') { return formMerge($_lang['ef_multiple_submit'], $fields); } } $fields['disclaimer'] = $disclaimer ? formMerge($disclaimer, $fields) : ""; $from = $from ? formMerge($from, $fields) : ""; $fromname = $from ? formMerge($fromname, $fields) : ""; if (isset($fields['subject'])) { $subject = $fields['subject']; } else { $subject = $subject ? formMerge($subject, $fields) : "from {$fromname}"; } $fields['subject'] = $subject; //make subject available in report & thank you page $report = $report ? formMerge($report, $fields) : ""; $keywords = $keywords ? formMerge($keywords, $fields) : ""; $to = formMerge($to, $fields); if (empty($to) || !strpos($to, '@')) { $nomail = 1; } if (!$nomail) { # check for mail selector field - select an email from to list if ($mselector && $fields[$mselector]) { $i = (int) $fields[$mselector]; $ar = explode(",", $to); if ($i > 0) { $i--; } if ($ar[$i]) { $to = $ar[$i]; } else { $to = $ar[0]; } } //set reply-to address //$replyto snippet parameter must contain email or fieldname if (!strstr($replyto, '@')) { $replyto = $fields[$replyto] && strstr($fields[$replyto], '@') ? $fields[$replyto] : $from; } # include PHP Mailer include_once $modx->config['base_path'] . 'manager/includes/controls/modxmailer.inc.php'; $mail = new MODxMailer(); # send form //defaults to html so only test sendasText $isHtml = $sendAsText == 1 || strstr($sendAsText, 'report') ? false : true; if (!$noemail) { if ($sendirect) { $to = $fields['email']; } $mail = new MODxMailer(); $mail->IsHTML($isHtml); $mail->From = $from; $mail->FromName = $fromname; $mail->Subject = $subject; $mail->Body = $report; AddAddressToMailer($mail, "replyto", $replyto); AddAddressToMailer($mail, "to", $to); AddAddressToMailer($mail, "cc", $cc); AddAddressToMailer($mail, "bcc", $bcc); AttachFilesToMailer($mail, $attachments); if (!$mail->Send()) { return 'Main mail: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo; } } # send user a copy of the report if ($ccsender && $fields['email']) { $mail = new MODxMailer(); $mail->IsHTML($isHtml); $mail->From = $from; $mail->FromName = $fromname; $mail->Subject = $subject; $mail->Body = $report; AddAddressToMailer($mail, 'to', $fields['email']); AttachFilesToMailer($mail, $attachments); if (!$mail->Send()) { return 'CCSender: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo; } } # send auto-respond email //defaults to html so only test sendasText $isHtml = $sendAsText == 1 || strstr($sendAsText, 'autotext') ? false : true; if ($autotext && $fields['email'] != '') { $autotext = formMerge($autotext, $fields); $mail = new MODxMailer(); $mail->IsHTML($isHtml); $mail->From = $autosender ? $autosender : $from; $mail->FromName = $autoSenderName ? $autoSenderName : $fromname; $mail->Subject = $subject; $mail->Body = $autotext; AddAddressToMailer($mail, 'to', $fields['email']); if (!$mail->Send()) { return 'AutoText: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo; } } //defaults to text - test for sendAsHtml $isHTML = $sendAsHTML == 1 || strstr($sendAsHtml, 'mobile') ? true : false; # send mobile email if ($mobile && $mobiletext) { $mobiletext = formMerge($mobiletext, $fields); $mail = new MODxMailer(); $mail->IsHTML($isHtml); $mail->From = $from; $mail->FromName = $fromname; $mail->Subject = $subject; $mail->Body = $mobiletext; AddAddressToMailer($mail, 'to', $mobile); $mail->Send(); } } //end test nomail # added in 1.4.2 - Protection against multiple submit with same form data if ($protectSubmit) { $_SESSION[$formid . '_hash'] = $hash; } //hash is set earlier # added in 1.4.2 - Limit the time between form submissions if ($submitLimit > 0) { $_SESSION[$formid . '_limit'] = time(); } # invoke OnMailSent event set by another script if ($eFormOnMailSent) { if ($isDebug && !function_exists($eFormOnMailSent)) { $fields['debug'] .= "eFormOnMailSent event: Could not find the function" . $eFormOnMailSent; } else { if ($eFormOnMailSent($fields) === false) { return; } } } if ($isDebug) { $debugText .= "<strong>Mail Headers:</strong><br />From: {$from} ({$fromname})<br />Reply-to:{$replyto}<br />To: {$to}<br />Subject: {$subject}<br />CC: {$cc}<br /> BCC:{$bcc}<br />"; if ($isDebug > 1) { $debugText .= "<br /><strong>Formats array:</strong><pre>" . var_export($formats, true) . '</pre>'; $debugText .= "<br /><strong>Fields array:</strong><pre>" . var_export($fields, true) . '</pre>'; } $fields['debug'] = $debugText; } # show or redirect to thank you page if ($gid == $modx->documentIdentifier) { if (!empty($thankyou)) { if ($isDebug && !strstr($thankyou, '[+debug+]')) { $thankyou .= '[+debug+]'; } if (isset($startupSource)) { efRegisterStartupBlock($startupSource, true); } //skip scripts if ($sendAsText) { foreach ($formats as $key => $fmt) { if ($fmt[2] == 'html') { $fields[$key] = str_replace("\n", '<br />', $fields[$key]); } } } $thankyou = formMerge($thankyou, $fields); return $thankyou; } else { return $_lang['ef_thankyou_message']; } } else { $url = $modx->makeURL($gid); $modx->sendRedirect($url); } return; // stop here } } else { //not postback //add debugging info to fields array if ($isDebug) { $debugText .= "<br /><strong>eForm configuration:</strong><pre>" . var_export($params, true) . '</pre>'; $fields['debug'] = $debugText; } //strip the eform attribute $regExpr = "#eform=([\"'])[^\\1]*?\\1#si"; $tpl = preg_replace($regExpr, '', $tpl); } // set vericode if ($vericode) { $_SESSION['eForm.VeriCode'] = $fields['vericode'] = substr(uniqid(''), -5); $fields['verimageurl'] = $modx->config['base_url'] . 'captcha.php?rand=' . mt_rand(); } # get SESSION data - thanks to sottwell if ($sessionVars) { $sessionVars = strpos($sessionVars, ',', 0) ? explode(',', $sessionVars) : array($sessionVars); foreach ($sessionVars as $varName) { if (empty($varName)) { continue; } $varName = trim($varName); if (isset($_SESSION[$varName]) && !empty($_SESSION[$varName])) { $fields[$varName] = isset($fields[$varName]) && $postOverides ? $fields[$varName] : $_SESSION[$varName]; } } } # invoke OnBeforeFormMerge event set by another script if ($eFormOnBeforeFormMerge) { if ($isDebug && !function_exists($eFormOnBeforeFormMerge)) { $fields['debug'] .= "eFormOnBeforeFormMerge event: Could not find the function " . $eFormOnBeforeFormMerge; } else { if ($eFormOnBeforeFormMerge($fields) === false) { return; } } } # build form if ($isDebug && !$fields['debug']) { $fields['debug'] = $debugText; } if ($isDebug && !strstr($tpl, '[+debug+]')) { $tpl .= '[+debug+]'; } //register css and/or javascript if (isset($startupSource)) { efRegisterStartupBlock($startupSource); } return formMerge($tpl, $fields); }
function displayForm($errorMessages, $missingFields, $member) { $logEntries = LogEntry::getLogEntries($member->getValue("id")); displayPageHeader("View member: " . $member->getValueEncoded("firstName") . " " . $member->getValueEncoded("lastName")); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } $start = isset($_REQUEST["start"]) ? (int) $_REQUEST["start"] : 0; $order = isset($_REQUEST["order"]) ? preg_replace("/[^ a-zA-Z]/", "", $_REQUEST["order"]) : "username"; ?> <form action="view_member.php" method="post" style="margin-bottom: 50px;"> <div style="width: 30em;"> <input type="hidden" name="memberId" id="memberId" value="<?php echo $member->getValueEncoded("id"); ?> " /> <input type="hidden" name="start" id="start" value="<?php echo $start; ?> " /> <input type="hidden" name="order" id="order" value="<?php echo $order; ?> " /> <label for="username"<?php validateField("username", $missingFields); ?> >Username *</label> <input type="text" name="username" id="username" value="<?php echo $member->getValueEncoded("username"); ?> " /> <label for="password">New password</label> <input type="password" name="password" id="password" value="" /> <label for="emailAddress"<?php validateField("emailAddress", $missingFields); ?> >Email address *</label> <input type="text" name="emailAddress" id="emailAddress" value="<?php echo $member->getValueEncoded("emailAddress"); ?> " /> <label for="firstName"<?php validateField("firstName", $missingFields); ?> >First name *</label> <input type="text" name="firstName" id="firstName" value="<?php echo $member->getValueEncoded("firstName"); ?> " /> <label for="lastName"<?php validateField("lastName", $missingFields); ?> >Last name *</label> <input type="text" name="lastName" id="lastName" value="<?php echo $member->getValueEncoded("lastName"); ?> " /> <label for="joinDate"<?php validateField("joinDate", $missingFields); ?> >Joined on *</label> <input type="text" name="joinDate" id="joinDate" value="<?php echo $member->getValueEncoded("joinDate"); ?> " /> <label<?php validateField("gender", $missingFields); ?> >Gender *</label> <label for="genderMale">Male</label> <input type="radio" name="gender" id="genderMale" value="m"<?php setChecked($member, "gender", "m"); ?> /> <label for="genderFemale">Female</label> <input type="radio" name="gender" id="genderFemale" value="f"<?php setChecked($member, "gender", "f"); ?> /> <label for="favoriteGenre">Favorite genre</label> <select name="favoriteGenre" id="favoriteGenre" size="1"> <?php foreach ($member->getGenres() as $value => $label) { ?> <option value="<?php echo $value; ?> "<?php setSelected($member, "favoriteGenre", $value); ?> ><?php echo $label; ?> </option> <?php } ?> </select> <label for="otherInterests">Other interests</label> <textarea name="otherInterests" id="otherInterests" rows="4" cols="50"><?php echo $member->getValueEncoded("otherInterests"); ?> </textarea> <div style="clear: both;"> <input type="submit" name="action" id="saveButton" value="Save Changes" /> <input type="submit" name="action" id="deleteButton" value="Delete Member" style="margin-right: 20px;" /> </div> </div> </form> <h2>Access log</h2> <table cellspacing="0" style="width: 30em; border: 1px solid #666;"> <tr> <th>Web page</th> <th>Number of visits</th> <th>Last visit</th> </tr> <?php $rowCount = 0; foreach ($logEntries as $logEntry) { $rowCount++; ?> <tr<?php if ($rowCount % 2 == 0) { echo ' class="alt"'; } ?> > <td><?php echo $logEntry->getValueEncoded("pageUrl"); ?> </td> <td><?php echo $logEntry->getValueEncoded("numVisits"); ?> </td> <td><?php echo $logEntry->getValueEncoded("lastAccess"); ?> </td> </tr> <?php } ?> </table> <div style="width: 30em; margin-top: 20px; text-align: center;"> <a href="view_members.php?start=<?php echo $start; ?> &order=<?php echo $order; ?> ">Back</a> </div> <?php displayPageFooter(); }
function displaypaso1($camposPendientes, $camposErroneos, $mensajeFoto) { if ($camposPendientes or $camposErroneos or $mensajeFoto != "correcto") { $error = ""; if ($camposPendientes) { $error = '<p class="error1">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete los campos en negrita de abajo y haga clic en Enviar para volver a enviar el formulario.</p>'; } if ($camposErroneos) { $error .= '<p class="error2">Hubo algunos problemas con el formulario que usted presentó. Por favor, introduzca valores adecuados en los campos</p>'; } if ($mensajeFoto != 'correcto') { $error .= '<p class="error3">Hubo algunos problemas con la foto. ' . $mensajeFoto . '</p>'; } } else { $error = '<p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p>'; } $generos = array('Western', 'Comedia', 'Ciencia', 'Terror', 'Suspense', 'Deportes'); $ocultosGeneros = ""; foreach ($generos as $valor) { $valorCampo = setValue2("generos", $valor); $ocultosGeneros .= '<input type="hidden" name="generos[]" value="' . $valorCampo . '">'; } $datos = array("error" => $error, "ocultosGeneros" => $ocultosGeneros, "validacionNombre" => validateField("nombre", $camposPendientes, $camposErroneos), "nombre" => setValue("nombre"), "validacionEdad" => validateField("edad", $camposPendientes, $camposErroneos), "edad" => setValue("edad"), "email" => setValue("email"), "validacionEmail" => validateField("email", $camposPendientes, $camposErroneos), "validacionFoto1" => validateField("foto1", $camposPendientes, $camposErroneos), "validacionFoto2" => validateField("foto2", $camposPendientes, $camposErroneos)); $plantilla = "plantillas/paso1.html"; $formulario = vista($datos, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm($errorMessages, $missingFields, $cliente) { displayPageHeader("<h2 class='text-center'>Area de Registro</h2>"); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } else { ?> <h3 class="text-center">Bienvenido a Tu Chef A Casa</h3> <p class="text-center">Para registrarte, por favor, rellena todos los campos</p> <p class="text-center">Todos los que estan marcados con (*) son obligatorios</p> <?php } ?> <form class="form-horizontal" role="form" action="registro.php" method="post"> <div class="form-group"> <input type="hidden" name="action" value="register" /> <label for="email"<?php validateField("email", $missingFields); ?> class="col-sm-2 control-label">E-mail: *</label> <div class="col-sm-10"> <input type="email" class="form-control" name="email" id="email" value=" <?php echo $cliente->getValueEncoded("email"); ?> " /> </div> </div> <div class="form-group"> <label for="pass" class="col-sm-2 control-label">Contraseña *</label> <div class="col-sm-10"> <input type="password" class="form-control" name="pass" id="pass" value="" /> </div> </div> <div class="form-group"> <label for="pass2"<?php if ($missingFields) { } ?> class="col-sm-2 control-label">Re-escribe contraseña *</label> <div class="col-sm-10"> <input type="password" class="form-control" name="pass2" id="pass2" value="" /> </div> </div> <div class="form-group"> <label for="nombre"<?php validateField("nombre", $missingFields); ?> class="col-sm-2 control-label">Nombre *</label> <div class="col-sm-10"> <input type="text" class="form-control" name="nombre" id="nombre" value=" <?php echo $cliente->getValueEncoded("nombre"); ?> " /> </div> </div> <div class="form-group"> <label for="apellidos"<?php validateField("apellidos", $missingFields); ?> class="col-sm-2 control-label">Apellidos *</label> <div class="col-sm-10"> <input type="text" class="form-control" name="apellidos" id="apellidos" value=" <?php echo $cliente->getValueEncoded("apellidos"); ?> " /> </div> </div> <div class="form-group"> <label for="telefono"<?php validateField("telefono", $missingFields); ?> class="col-sm-2 control-label">Telefono *</label> <div class="col-sm-10"> <input type="text" class="form-control" name="telefono" id="telefono" value=" <?php echo $cliente->getValueEncoded("telefono"); ?> " /> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" name="submitButton" id="submitButton" class="btn btn-default" value="Send Details">Enviar</button> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="reset" name="resetButton" id="resetButton" value="Reset Form" class="btn btn-default">Reset</button> </div> </div> </form> <?php displayPageFooter(); }
function displayForm($errorMessages, $missingFields, $pedidos) { if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } ?> <form role="form" action="pedidosplatos.php" method="post"> <input type="hidden" name="action" value="register" /> <div class="form-group"> <label for="fecha"<?php validateField("fecha", $missingFields); ?> ></label> <div class="input-group date form_date col-md-5" data-date="" data-date-format="dd/mm/yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd"> <input class="form-control" size="16" type="text" value="" name="fecha" readonly> <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> </div> </div> <script type="text/javascript" src="./jquery/jquery-1.8.3.min.js" charset="UTF-8"></script> <script type="text/javascript" src="js/bootstrap.min.js"></script> <script type="text/javascript" src="bootstrap-datetimepicker.js" charset="UTF-8"></script> <script type="text/javascript" src="locales/bootstrap-datetimepicker.es.js" charset="UTF-8"></script> <?php $dates = ""; list($fechas) = Pedidos::getFecha(); foreach ($fechas as $fecha) { $dates .= "'" . $fecha->getValueEncoded("fecha") . "',"; } $dates = substr($dates, 0, -1); ?> <script type="text/javascript"> var array = [<?php echo $dates; ?> ]; $('.form_date').datetimepicker({ language: 'es', startDate: "+1d", autoclose: 1, todayHighlight: 1, startView: 2, minView: 2, forceParse: 0, beforeShowDay: function(date){ var string = jQuery.datepicker.formatDate('yy-mm-dd', date); return [ array.indexOf(string) == -1 ] } }); </script> <br> <div class="form-group"> <label for="hora">Hora: </label> <select name="hora"> <?php for ($i = 0; $i <= 23; $i++) { if ($i < 10) { echo "<option value='0" . $i . "'>0" . $i . "</option>"; } else { echo "<option value=" . $i . ">" . $i . "</option>"; } } ?> </select> <label for="minuto"></label> <select name="minuto"> <?php for ($i = 0; $i <= 59; $i++) { if ($i < 10) { echo "<option value='0" . $i . "'>0" . $i . "</option>"; } else { echo "<option value=" . $i . ">" . $i . "</option>"; } } ?> </select> </div> <div class="form-group"> <label for="localidad">Localidad: <select name="localidad"></label> <?php list($localidades) = Localidad::getLocalidad(); foreach ($localidades as $localidad) { echo "<option value='" . $localidad->getValueEncoded("cp") . "'>" . $localidad->getValueEncoded("nombre") . "</option>"; } ?> </select> </div> <div class="form-group"> <label for="direccion" <?php validateField("direccion", $missingFields); ?> >Dirección: </label> <input class="form-control" type="text" name="direccion" /> </div> <div class="form-group"> <label for="comensales">Comensales:</label> <select name="comensales"> <?php for ($i = 1; $i <= 12; $i++) { echo "<option value=" . $i . ">" . $i . "</option>"; } ?> </select> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </div> <?php displayPageFooter(); }
function displayForm2() { $ciudades = array('Roma', 'Paris', 'Nueva York', 'Londres', 'Berlin', 'Atenas'); $ocultosInformacion = ""; $ocultosCiudades = ""; foreach ($ciudades as $valor) { $valorCampo = setValue2("ciudades", $valor); $ocultosCiudades .= '<input type="hidden" name="ciudades[]" value="' . $valorCampo . '">'; } $informacion = array('Correo Postal', 'Email'); foreach ($informacion as $valor) { $valorCampo = setValue2("informacion", $valor); $ocultosInformacion .= '<input type="hidden" name="informacion[]" value="' . $valorCampo . '">'; } $datos = array("error" => $error, "ocultosCiudades" => $ocultosCiudades, "ocultosInformacion" => $ocultosInformacion, "validacionNombre" => validateField("nombre", $camposPendientes, $camposErroneos), "nombre" => setValue("nombre"), "validacionApellidos" => validateField("apellidos", $camposPendientes, $camposErroneos), "apellidos" => setValue("apellidos"), "validacionDireccion" => validateField("direccion", $camposPendientes, $camposErroneos), "direccion" => setValue("direccion"), "validacionTelefono" => validateField("telefono", $camposPendientes, $camposErroneos), "telefono" => setValue("telefono"), "email" => setValue("email"), "validacionEmail" => validateField("email", $camposPendientes, $camposErroneos), "validacionFoto" => validateField("foto", $camposPendientes, $camposErroneos)); $plantilla = "plantillas/paso1.html"; $formulario = vista($datos, $plantilla); $datos = array("titulo" => TITULO, "formulario" => $formulario); $plantilla = "plantillas/plantilla.html"; $html = vista($datos, $plantilla); print $html; }
function displayForm($errorMessages, $missingFields, $member) { displayPageHeader("Sign up for the twitter club!"); if ($errorMessages) { foreach ($errorMessages as $errorMessage) { echo $errorMessage; } } else { ?> <p>Thanks for choosing to join our twitter club.</p> <p>To register, please fill in your details below and click Send Details.</p> <p>Fields marked with an asterisk (*) are required.</p> <?php } ?> <form action="register.php" method="post" style="margin-bottom: 50px;"> <div style="width: 30em;"> <input type="hidden" name="action" value="register" /> <label for="username"<?php validateField("username", $missingFields); ?> >Username *</label> <input type="text" name="username" id="username" value="<?php echo $member->getValueEncoded("username"); ?> " /> <label for="first_name"<?php validateField("first_name", $missingFields); ?> >First name *</label> <input type="text" name="first_name" id="first_name" value="<?php echo $member->getValueEncoded("first_name"); ?> " /> <label for="last_name"<?php validateField("last_name", $missingFields); ?> >Last name *</label> <input type="text" name="last_name" id="last_name" value="<?php echo $member->getValueEncoded("last_name"); ?> " /> <label for="email"<?php validateField("email", $missingFields); ?> >Email address *</label> <input type="text" name="email" id="email" value="<?php echo $member->getValueEncoded("email"); ?> " /> <div style="clear: both;"> <input type="submit" name="submitButton" id="submitButton" value="Save User" /> <input type="reset" name="resetButton" id="resetButton" value="Reset Form" style="margin-right: 20px;" /> </div> </div> </form> <?php displayPageFooter(); }
function displayForm($missingFields) { ?> <h1>Membership Form</h1> <?php if ($missingFields) { ?> <p class="error">There were some problems with the form you submitted. Please complete the fields highlighted below and click Send Details to resend the form.</p> <?php } else { ?> <p>Thanks for choosing to join The Widget Club. To register, please fill in your details below and click Send Details. Fields marked with an asterisk (*) are required.</p> <?php } ?> <form action="registration.php" method="post"> <div style="width: 30em;"> <label for="firstName"<?php validateField("firstName", $missingFields); ?> >First name *</label> <input type="text" name="firstName" id="firstName" value="<?php setValue("firstName"); ?> " /> <label for="lastName"<?php validateField("lastName", $missingFields); ?> >Last name *</label> <input type="text" name="lastName" id="lastName" value="<?php setValue("lastName"); ?> " /> <label for="password1"<?php if ($missingFields) { echo ' class="error"'; } ?> >Choose a password *</label> <input type="password" name="password1" id="password1" value="" /> <label for="password2"<?php if ($missingFields) { echo ' class="error"'; } ?> >Retype password *</label> <input type="password" name="password2" id="password2" value="" /> <label<?php validateField("gender", $missingFields); ?> >Your gender: *</label> <label for="genderMale">Male</label> <input type="radio" name="gender" id="genderMale" value="M"<?php setChecked("gender", "M"); ?> /> <label for="genderFemale">Female</label> <input type="radio" name="gender" id="genderFemale" value="F"<?php setChecked("gender", "F"); ?> /> <label for="favoriteWidget">What's your favorite widget? *</label> <select name="favoriteWidget" id="favoriteWidget" size="1"> <option value="superWidget"<?php setSelected("favoriteWidget", "superWidget"); ?> >The SuperWidget</option> <option value="megaWidget"<?php setSelected("favoriteWidget", "megaWidget"); ?> >The MegaWidget</option> <option value="wonderWidget"<?php setSelected("favoriteWidget", "wonderWidget"); ?> >The WonderWidget</option> </select> <label for="newsletter">Do you want to receive our newsletter?</label> <input type="checkbox" name="newsletter" id="newsletter" value="yes"<?php setChecked("newsletter", "yes"); ?> /> <label for="comments">Any comments?</label> <textarea name="comments" id="comments" rows="4" cols="50"><?php setValue("comments"); ?> </textarea> <div style="clear: both;"> <input type="submit" name="submitButton" id="submitButton" value="Send Details" /> <input type="reset" name="resetButton" id="resetButton" value="Reset Form" style="margin-right: 20px;" /> </div> </div> </form> <?php }
function displayForm($camposPendientes) { cabecera(); if ($camposPendientes) { ?> <p class="error">Hubo algunos problemas con el formulario que usted presentó. Por favor, complete correctamente los campos remarcados de abajo y haga clic en Enviar para volver a enviar el formulario.</p> <?php } else { ?> <p>por favor, rellene sus datos a continuación y haga clic en Enviar. Los campos marcados con un asterisco (*) son obligatorios.</p> <?php } ?> <form action = "" method = "post"> <fieldset> <label for="nombreUsuario" <?php validateField("nombreUsuario", $camposPendientes); ?> >Introduce tu nombre * </label> <input type = "text" name = "nombreUsuario" id="nombreUsuario" value="<?php setValue("nombreUsuario"); ?> "> <label for="apellidos" <?php validateField("apellidos", $camposPendientes); ?> >y tus apellidos *</label> <input type = "text" name = "apellidos" id="apellidos" value="<?php setValue("apellidos"); ?> " ><br><br> <label for="tipoMusica">¿Qué tipo de música te gusta escuchar?</label> <select name="tipoMusica[]" id="tipoMusica" size="4" multiple="multiple"> <option value="Rock"<?php setSelected("tipoMusica", "Rock"); ?> >Rock </option> <option value="Pop"<?php setSelected("tipoMusica", "Pop"); ?> >Pop </option> <option value="Regee"<?php setSelected("tipoMusica", "Regee"); ?> >Regee </option> <option value="Clásica"<?php setSelected("tipoMusica", "Clásica"); ?> >Clásica </option> </select><br><br> ¿Que tipo de libros lees? <br> <label for="novelaNegra">Novela Negra</label> <input type="checkbox" name="tipoLibros[]" id="novelaNegra" value="Novela Negra"<?php setChecked("tipoLibros", "Novela Negra"); ?> ><br> <label for="cienciaFiccion">Ciencia Ficción</label> <input type="checkbox" name="tipoLibros[]" id="cienciaFiccion" value="Ciencia Ficción" <?php setChecked("tipoLibros", "Ciencia Ficción"); ?> ><br> <label for="fantasia">Fantasía</label> <input type="checkbox" name="tipoLibros[]" id="fantasia" value="Fantasía" <?php setChecked("tipoLibros", "Fantasía"); ?> ><br><br> <input type = "submit" name="enviar" value="Enviar"> </fieldset> </form> <?php pie(); }
function displayForm($missingFields) { $results = array("pageTitle" => "Membership Form", "scriptUrl" => "registration.php", "missingFields" => $missingFields, "firstNameAttrs" => validateField("firstName", $missingFields), "firstNameValue" => setValue("firstName"), "lastNameAttrs" => validateField("lastName", $missingFields), "lastNameValue" => setValue("lastName"), "genderAttrs" => validateField("gender", $missingFields), "genderMChecked" => setChecked("gender", "M"), "genderFChecked" => setChecked("gender", "F"), "favoriteWidgetOptions" => array("superWidget" => setSelected("favoriteWidget", "superWidget"), "megaWidget" => setSelected("favoriteWidget", "megaWidget"), "wonderWidget" => setSelected("favoriteWidget", "wonderWidget")), "newsletterChecked" => setChecked("newsletter", "yes"), "commentsValue" => setValue("comments")); require "templates/registration_form.php"; }
function student_information($missingFields, $adultStudent) { $output = '学生(Student):<br/>' . "\n"; $output .= '<table>'; $output .= '<tr><th' . validateField("stu_last_name", $missingFields) . '><label for="stu_last_name">Last Name</label></th>' . '<th' . validateField("stu_first_name", $missingFields) . '><label for="stu_first_name">First Name</label></th>' . '<th' . validateField("stu_gender", $missingFields) . '><label for="stu_gender">Gender</label></th>' . ($adultStudent ? '' : '<th>Birth Date</th>') . '<th' . validateField("stu_phone", $missingFields) . '><lable for="stu_phone">Phone</label></th>' . ($adultStudent ? '<th' . validateField("stu_email", $missingFields) . '><lable for="stu_email">Email</label></th>' : '') . '</tr>' . "\n"; $output .= '<tr><td><input style="width:98%;" type="text" name="stu_last_name" placeholder="Student Last Name" value="' . setValue("stu_last_name") . '" requiredxx </td>'; $output .= '<td><input style="width:98%;" type="text" name="stu_first_name" placeholder="Student First Name" value="' . setValue("stu_first_name") . '" requiredxx </td>'; $output .= '<td><label for="stu_gender"><input type="radio" class="radio" name="stu_gender" value="M" ' . setChecked("stu_gender", "M") . '/>Male</label> <label for="stu_gender"><input type="radio" class="radio" name="stu_gender" value="F" ' . setChecked("stu_gender", "F") . '/>Female</label> </td>'; if (!$adultStudent) { $output .= '<td><input style="width:98%;" type="date" name="stu_birth_date" value=""</td>'; } $output .= '<td><input style="width:98%;" type="tel" name="stu_phone" placeholder="Student Phone Num" value="' . setValue("stu_phone") . '" requiredxx </td>'; if ($adultStudent) { $output .= '<td><input style="width:98%;" type="email" name="stu_email" placeholder="Student Email" value="' . setValue("stu_email") . '" requiredxx </td></tr>' . "\n"; } else { $output .= '</tr>' . "\n"; } $output .= '<tr><th colspan="2">City</th><th>State</th><th colspan="2">Zip</th></tr>' . "\n"; $output .= '<tr><td colspan="2"><input type="text" name="stu_city" value="' . setValue("stu_city") . '"</td>'; $output .= '<td><input style="width:98%;" type="text" name="stu_state" value="' . setValue("stu_state") . '"</td>'; $output .= '<td colspan=2><input type="text" name="stu_zip" value="' . setValue("stu_zip") . '"</td></tr></table>' . "\n"; if (!$adultStudent) { $output .= '父母/监护人(Parent/Guardien):<br/>' . "\n"; $output .= '<table>'; $output .= '<tr><th' . validateField("parent1_last_name", $missingFields) . '>Last Name</th>' . '<th' . validateField("parent1_first_name", $missingFields) . '>First Name</th><th>Relation</th>' . '<th' . validateField("parent1_phone", $missingFields) . '>Phone</th>' . '<th' . validateField("parent1_email", $missingFields) . '>Email</th></tr>' . "\n"; $output .= '<tr><td><input style="width:98%;" type="text" name="parent1_last_name" placeholder="First Guardien Last Name" value="' . setValue("parent1_last_name") . '" requiredxx </td>'; $output .= '<td><input style="width:98%;" type="text" name="parent1_first_name" placeholder="First Guardien First Name" value="' . setValue("parent1_first_name") . '" requiredxx "</td>'; $output .= '<td><input style="width:98%;" type="text" name="parent1_relation" value="' . setValue("parent1_relation") . '"</td>'; $output .= '<td><input style="width:98%;" type="text" name="parent1_phone" placeholder="First Guardien Phone Num" value="' . setValue("parent1_phone") . '" requiredxx </td>'; $output .= '<td><input style="width:98%;" type="email" name="parent1_email" placeholder="First Guardien Email" value="' . setValue("parent1_email") . '" requiredxx </td></tr>'; $output .= '<tr><td><input style="width:98%;" type="text" name="parent2_last_name" value="' . setValue("parent2_last_name") . '"</td>'; $output .= '<td><input style="width:98%;" type="text" name="parent2_first_name" value="' . setValue("parent2_first_name") . '"</td>'; $output .= '<td><input style="width:98%;" type="text" name="parent2_relation" value="' . setValue("parent2_relation") . '"</td>'; $output .= '<td><input style="width:98%;" type="text" name="parent2_phone" value="' . setValue("parent2_phone") . '"</td>'; $output .= '<td><input style="width:98%;" type="email" name="parent2_email" value="' . setValue("parent2_email") . '"</td></tr></table>'; } return $output; }