Skip to content

Instantly share code, notes, and snippets.

@alfintechcomputer
Created November 15, 2020 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfintechcomputer/d48e4f9da70ecc2473ea6bec1be046c6 to your computer and use it in GitHub Desktop.
Save alfintechcomputer/d48e4f9da70ecc2473ea6bec1be046c6 to your computer and use it in GitHub Desktop.
HTML Forms using PHP
<?php
function has_presence($value) {
return isset($value) and $value !== '';
}
function max_length($value, $max) {
return strlen($value) <= $max;
}
function min_length($value, $min) {
return strlen($value) >= $min;
}
function has_inclusion($value, $set) {
return in_array($value, $set);
}
function form_errors($errors = array()) {
$output = '';
if(!empty($errors)){
$output .= '<div class="alert alert-danger">';
$output .= 'You might need to fix a few things!<br>';
$output .= '<ul>';
foreach($errors as $key => $error) {
$output .= '<li>'. $error .'</li>';
}
$output .= '</ul>';
$output .= '</div>';
}
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment