<?php require_once "../vendor/autoload.php"; use azi\Validator; $v = new Validator(); if ($_POST) { $rules = array('email' => 'email|required', 'password' => 'required', 'confirm_password' => 'same:password|required'); if ($v->validate($_POST, $rules)->failed()) { $v->goBackWithErrors(); } echo "data validated do whatever you want here..."; }
<label>Email : <input type="text" name="email"> </label> <?php echo Validator::error('email') ? Validator::error('email', '<span class="error">:message</span>') : ""; ?> </p> <p> <label>Password : <input type="password" name="password"> </label> <?php echo Validator::error('password') ? Validator::error('password', '<span class="error">:message</span>') : ""; ?> </p> <p> <label>Confirm Password : <input type="password" name="confirm_password"> </label> <?php echo Validator::error('confirm_password') ? Validator::error('confirm_password', '<span class="error">:message</span>') : ""; ?> </p> <p> <input type="submit" name="submit"> </p> </form> </body> </html>