Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create form fields with PHP
<?php
function create_form_field($formelement, $label = "", $db_value = "", $length = 25) {
$form_field = ($label != "") ? "<label for=\"".$formelement."\">".$label."</label>\n" : "";
$form_field .= " <input name=\"".$formelement."\" type=\"text\" size=\"".$length."\" value=\"";
if (isset($_REQUEST[$formelement])) {
$form_field .= $_REQUEST[$formelement];
} elseif (isset($db_value) && !isset($_REQUEST[$formelement])) {
$form_field .= $db_value;
} else {
$form_field .= "";
}
$form_field .= "\">\n";
return $form_field;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment