public function actionUpdate() { $model = new FormAlumnos(); $msg = null; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = Alumnos::findOne($model->id_alumno); if ($table) { /* Le asignamos a cada columna su nuevo valor */ $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->nota_final = $model->nota_final; /* Llamamos al metodo update */ if ($table->update()) { $msg = "El alumno ha sido actualizado correctamente"; } else { $msg = "El alumno no ha podido ser modificado, intentelo mas tarde"; } } else { $msg = "El alumno seleccionado no ha sido encontrado "; } } else { return getErrors(); } } if (Yii::$app->request->get("id_alumno")) { $id_alumno = Html::encode($_GET["id_alumno"]); if ((int) $id_alumno) { /* Guardamos en table la clave primaria con el metodo findOne del objeto Alumno */ $table = Alumnos::findOne($id_alumno); /* Validamos que el registro exista */ if ($table) { /* Cargamos la data en los campos del formulario */ $model->id_alumno = $table->id_alumno; $model->nombre = $table->nombre; $model->apellidos = $table->apellidos; $model->clase = $table->clase; $model->nota_final = $table->nota_final; } else { return $this->redirect(["site/view"]); } } else { return $this->redirect(["site/view"]); } } else { return $this->redirect(["site/view"]); } return $this->render("update", ["model" => $model, "msg" => $msg]); }
<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" href="assets/css/font-awesome-ie7.css"> <![endif]--> <div class="body" id="mg-wrapper" data-target=".body" data-spy="scroll" data-twttr-rendered="true">'; $infos = getInfos(); if ($infos) { echo '<div class="border-box">'; foreach ($infos as $info) { echo '<div class="control-group success"> <span class="help-block center">' . $info . '</span> </div>'; } echo '</div>'; } $errors = getErrors(); if ($errors) { echo '<div class="border-box">'; foreach ($errors as $error) { echo '<div class="control-group error"> <span class="help-block center">' . $error . '</span> </div>'; } echo '</div>'; } echo $CONTENT; echo '</div>'; return ob_get_clean();
function outputErrors() { $errors = getErrors(); if (COUNT($errors)) { $htmlArr = array(); foreach ($errors as $error) { $htmlArr[] = "<li>" . $error . "</li>"; } return "<ul class='pageErrors'>" . implode("<br/>", $htmlArr) . "</ul>"; } }
</div> <div> <label for="password1">password:</label> <input type="password" id="password1" name="password1" class="<?php echo getClass($errors, 'password1'); ?> "> <?php echo getErrors($errors, 'password1'); ?> </div> <div> <label for="password2">repeat password:</label> <input type="password" id="password2" name="password2" class="<?php echo getClass($errors, 'password2'); ?> "> <?php echo getErrors($errors, 'password2'); ?> </div> <div> <button type="submit">Register</button> </div> <?php echo $_POST && $check ? "<h3>Registration successful.</h3><h3>username: "******"</h3><h3>password hash: " . htmlentities($encrypted) . "</h3>" : ''; ?> </form> </div> </body> </html>
$total = count($titles); $count = 0; foreach ($titles as $key => $value) { $count++; echo $count . "/" . $total . " - " . $value . " - " . $key . "\n"; echo "Testando IAH - indice de Autor \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&index=AU&format=iso.pft&lang=i&limit=" . $key; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); echo "Testando IAH - indice de Autor letra A \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&index=AU&format=iso.pft&lang=i&limit=" . $key . " &indexRoot=A&nextAction=show index&selectedIndex=^l1^nAu^pAutor^eAutor^iAuthor^xAU ^yPREINV^uAU_^mAU_&indexSearch=^nAu^pAutor^eAutor^iAuthor^xAU ^yPREINV^uAU_^mAU_"; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); echo "Testando IAH - indice de Assunto letra A \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&index=AU&format=iso.pft&lang=i&limit=" . $key . "&indexRoot=A&nextAction=show index&selectedIndex=^l1^nKw^pAssunto^eMateria^iSubject^xKW ^yPREINV^uKW_^mKW_&indexSearch=^nKw^pAssunto^eMateria^iSubject^xKW ^yPREINV^uKW_^mKW_"; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); echo "Testando IAH - indice de Resumo letra A \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&format=iso.pft&lang=i&limit=" . $key . "&indexRoot=A&nextAction=show index&selectedIndex=^l1^nAb^pResumo^eResumen^iAbstract^xAB ^yPREINV^uAB_^mAB_&indexSearch=^nAb^pResumo^eResumen^iAbstract^xAB ^yPREINV^uAB_^mAB_"; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); echo "Testando IAH - indice de Titulo letra A \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&format=iso.pft&lang=i&limit=" . $key . "&indexRoot=A&nextAction=show index&selectedIndex=^l1^nTi^pPalavras do título^ePalabras del título^iTitle words^xTI ^yPREINV^uTI_^mTI_&indexSearch=^nTi^pPalavras do título^ePalabras del título^iTitle words^xTI ^yPREINV^uTI_^mTI_"; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); echo "Testando IAH - indice de Ano de Publicacao \n"; $URL = "http://" . $domain . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^d" . $value . "&format=iso.pft&lang=i&limit=" . $key . "&nextAction=show index&selectedIndex=^l1^nYr^pAno de publicação^eAño de publicación^iPublication year^xYR ^yPREINV^uYR_^mYR_^tshort&indexSearch=^nYr^pAno de publicação^eAño de publicación^iPublication year^xYR ^yPREINV^uYR_^mYR_^tshort"; $content = file_get_contents(formatURL($URL)); getErrors($content, $URL); } echo "DONE";
<?php foreach (getErrors() as $key => $value) { if ($key == "message") { echo "<div class='alert alert-success' role='alert'>" . $value . "</div>"; } else { if ($key == "error") { echo "<div class='alert alert-danger' role='alert'>" . $value . "</div>"; } } }
</head> <body> <div class="container"> <div class="col-md-6 col-md-offset-3"> <h2>Login</h2> <form action="auth.php" method="post"> <div class="form-group"> <input type="text" class="form-control" name="username" placeholder="Username"> </div> <div class="form-group"> <input type="password" class="form-control" name="password" placeholder="Password"> </div> <button type="submit" class="btn btn-default">Log in</button> or <span><a href="register.php">register</a></span> </form> <?php foreach (getErrors() as $value) { echo "<div class='alert alert-danger' role='alert'>" . $value . "</div>"; } ?> </div> </div> <!-- script references --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script type = "text/javscript"> </script> </body> </html>
} require("../../library/include/header.php"); $script_transl=HeadMain(); $gForm = new GAzieForm(); $linkHeaders=new linkHeaders($script_transl['header']); echo "<form method=\"POST\" name=\"select\">\n"; echo "<input type=\"hidden\" value=\"".$form['hidden_req']."\" name=\"hidden_req\" />\n"; echo "<input type=\"hidden\" value=\"".$form['ritorno']."\" name=\"ritorno\" />\n"; echo "<div align=\"center\" class=\"FacetFormHeaderFont\">".$script_transl['title'].$script_transl['year']; $gForm->selectNumber('year',$form['year'],1,$form['year']-10,$form['year']+10,'FacetSelect','year'); echo "\t </div>\n"; echo "<table class=\"Tlarge\">\n"; $ctrl = 0; $ctrl_reg = ""; $m=getErrors($form['year']); if (sizeof($m) > 0) { $ctr_mv=''; echo "<tr>"; $linkHeaders=new linkHeaders($script_transl['header']); $linkHeaders->output(); echo "</tr>"; while (list($key, $mv) = each($m)) { if ($mv['err']=='P'){ $p='red" >'.$mv["pr"].$script_transl['expect'].$mv["ex"]; $nred=''; $n=$mv["nd"]; } else { $p='">'.$mv["pr"]; $nred='red'; $n=$mv["nd"].' ('.$script_transl['expect'].$mv["ex"].')';
"> <?php echo getErrors($errors, 'num1'); ?> </div> <div> <label for="op">Operation:</label> <select name="op" id="op"> <option value="1" <?php echo $op == 1 ? 'selected' : ''; ?> >Celsius to Fahrenheit</option> <option value="2" <?php echo $op == 2 ? 'selected' : ''; ?> >Fahrenheit to Celsius</option> </select> <?php echo getErrors($errors, 'op'); ?> </div> <div> <button type="submit">Convert</button> </div> <?php echo $_POST && $result ? "<h3>{$result}</h3>" : ''; ?> </form> </div> </body> </html>
<head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/index.css"> </head> <body> <div> <form action="index.php" method="post"> <div> <label for="string">Enter 10 numbers separated with <b>,</b></label> <input type="text" id="string" name="string" class="<?php echo getClass($errors, 'string'); ?> " value="<?php echo htmlentities($string); ?> "> <?php echo getErrors($errors, 'string'); ?> </div> <div> <button type="submit">Sort</button> </div> <?php echo $_POST && $result ? "<p>{$result}</p>" : ''; ?> </form> </div> </body> </html>
" value="<?php echo htmlentities($surname); ?> "> <?php echo getErrors($errors, 'surname'); ?> </div> <div> <label for="birthdate">Date of Birth:</label> <input type="date" id="birthdate" name="birthdate" class="<?php echo getClass($errors, 'birthdate'); ?> " value="<?php echo htmlentities($birthdate); ?> "> <?php echo getErrors($errors, 'birthdate'); ?> </div> <div> <button type="submit">Submit</button> </div> <?php echo $_POST && $result ? "<p>Registration successful.</p>" : ''; ?> </form> </div> </body> </html>
/** * Get form validation errors. * @param Form| $form * @return array */ protected function getAllFormErrorMessages($form) { // DEBUG //var_dump($form->getErrors($deep)); //die(); $messagesArray = array(); foreach ($form->getErrors() as $key => $error) { if ($error->getMessagePluralization() !== null) { $messagesArray['message'] = $this->translator->transChoice($error->getMessage(), $error->getMessagePluralization(), $error->getMessageParameters(), 'validators'); } else { $messagesArray['message'] = $this->translator->trans($error->getMessage(), array(), 'validators'); } } // Children errors foreach ($form->all() as $name => $child) { $errors = $this->getAllFormErrorMessages($child); if (!empty($errors)) { $messagesArray[$name] = $errors; } } return $messagesArray; }