PHP Classes

File: examples/examplefile.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  PHP Validation One Library  >  examples/examplefile.php  >  Download  
File: examples/examplefile.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Validation One Library
Fetch and validate forms and request values
Author: By
Last change: Update of examples/examplefile.php
Date: 2 years ago
Size: 737 bytes
 

Contents

Class file image Download
<form method="post" enctype="multipart/form-data">
    <input type="file" class="custom-file-input" name="frm_image" id="frm_image"><br>
    <button type="submit" class="btn btn-primary" name="button" value="submit">Submit</button>
</form>

<?php

use eftec\ValidationOne;


include
"common.php";


$validaton=new ValidationOne("frm_");

$file=$validaton
   
->def("")
    ->
ifFailThenDefault(false) // if fails then we show the same value however it triggers an error
   
->type("file")
    ->
condition("image","The file is not a right image")
    ->
condition("ext","The file is incorrect",['jpg','png'])
    ->
condition("req","this value is required")
    ->
getFile('image',false);

var_dump($file);
echo
"<br>validations:";
var_dump($validaton->getMessages());

For more information send a message to info at phpclasses dot org.