WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Dynamic form field
Categories : PHP, HTML and PHP, Form Processing Click here to Update Your Picture
Olaf Lederer
Date : Mar 06th 2005
Grade : 2 of 5 (graded 7 times)
Viewed : 27664
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Olaf Lederer
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

This is another dynamic form element from my collection. I use this function in forms where a value of a database will be filled inside the form field. This is an easy way to get the right value inside the field if the form is submitted before and/or the process is stopped because some validation issue occurs. You can use the (optional) database value attribute as a default value, too.

<?php
function create_form_field($formelement, $label, $db_value = "", $length = 25) {
   
$form_field = "<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 .= "\"><br>\n";
    return
$form_field;       
}
// example use
echo "<form method=\"post\">\n";
echo
create_form_field("test", "test label", "db val");
echo
"\n<input type=\"submit\" name=\"submit\">\n";
echo
"</form>";
?>



The Nearly Perfect Contact Us Form
Categories : PHP, Form Processing, HTML and PHP
Simple PHP Form Field Generator
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
Check empty fields
Categories : PHP, HTML and PHP, Form Processing
Sql Builder
Categories : PHP, HTML and PHP, Databases, General SQL, Form Processing
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
PageRank Display
Categories : Search Engines, HTML and PHP, PHP
Print out array key => value in colored HTML
Categories : PHP, Arrays, HTML and PHP
If you want to create select buttons featuring current date this example will show you how...
Categories : Date Time, HTML and PHP, PHP
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used.
Categories : HTML and PHP, PHP, Date Time
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
Customer feedback or simple emailer - A PHP script that enables your visitors to send you emails.
Categories : PHP, Email, Form Processing
This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time.
Categories : PHP, Calendar, Date Time, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
 Jose Santos wrote : 1283
This type of kinds is very easy and simple!
Why dont use templates ??
The templates has advantage to isolate the code (PHP) of the HTML.
Using templates, the code is more cleary and easy to understand.
See functions to work with templates insided in the PEAR of PHP.
Links:
http://pear.php.net/manual/en/
http://pear.php.net/package/HTML_Template_PHPLIB/docs/1.3/apidoc/HTML_Template_PHPLIB-1.3/Template_PHPLIB.html
 
 Olaf Lederer wrote :1284
You are right it`s possible to do this with other technics. The example is meant for people which don`t want to use smarty (or whatever). I use this kind of function in some quick CMS forms and it works very fast for me.