LOForm is a streamlined PHP class designed to simplify the creation and management of HTML forms. With its intuitive API, developers can easily define form fields, process submissions, and render consistent, well-structured form elements.
Whether you're building a basic contact form, a multi-step survey, or a form with specialized input types, LOForm delivers a flexible and scalable solution—all without the overhead of complex frameworks or heavy dependencies.
Refresh the webpage to see a new example.
<?php
require_once 'loform.php';
$form = new LOForm();
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST)) {
$form->load($_POST);
// Save blog post to database
echo "<p>Post saved successfully!</p>";
exit;
}
$form->field([
'type' => 'text',
'name' => 'title',
'title' => 'Post Title',
'holder' => 'Enter title',
'required' => true
]);
$form->field([
'type' => 'wysiwyg',
'name' => 'content',
'title' => 'Post Content',
'required' => true
]);
$form->field([
'type' => 'button',
'holder' => 'Publish Post!',
'button_type' => 'submit'
]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>New Blog Post</title>
<?php echo LOForm::header(); ?>
</head>
<body>
<h1>Create New Post</h1>
<?php
echo $form->form([
'action' => '',
'method' => 'post',
'print' => false
]);
?>
</body>
</html>
<?php
echo LOForm::footer();<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>New Blog Post</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/LacasuriOrtodoxe/LOEditor@latest/loeditor.min.css" />
<script src="https://cdn.jsdelivr.net/gh/jquery/jquery@latest/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/LacasuriOrtodoxe/LOEditor@latest/loeditor.min.js"></script>
</head>
<body>
<h1>Create New Post</h1>
<form action="" method="post">
<div class="form-group">
<label for="input-iayu397">Post Title</label>
<input type="text" name="title" id="input-iayu397" value="" placeholder="Enter title" />
</div>
<div class="form-group">
<label for="input-npsvtfm">Post Content</label>
<textarea class="loeditor" name="content" id="input-npsvtfm" placeholder="">
</textarea>
</div>
<div class="form-group">
<button type="submit">Publish Post!</button>
</div>
</form>
</body>
</html>
<script>
var textareas = document.querySelectorAll(".loeditor");
for(i=0;i<textareas.length;i++) {
console.log(textareas[i])
new LOEditor(textareas[i], {
upload: "upload.php"
});
}
</script>