TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-13-2007, 09:01 PM   #1 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default Form Function

Just wanted some thoughts on the the efficiency of this function

PHP Code:
    function FormGenerate($frmname,$to,$values=array(),$echo=false,$len='30',$submitto='',$special=array())
        {
            
//set up the form and create the action
                        
$submit = !empty($submitto) ? "onSubmit='".$submitto."'" '';
            
$data '<form name="'.$frmname.'" method="post" action="'.$this->siteinfo['url'] . $to.'" '.$submit.'>
                        <table>'
;
            
                     
                        
$tag reset(array_keys($special));
                        
$rep reset($special);
            
//start the loop, this method is supposed to be more efficient
            
while(list(, $v) = each($values))
            { 

                
$type = ($v == $tag) ? $rep 'text';
                
//create the table and such
                
$data .= '
                    <tr>
                <td><label for="'
.$v.'">'.$v.'</label><td>
                            <td><input name="'
.$v.'" id="'.$v.'" value="" size="'.$len.'" maxlength="255" type="'.$type.'"></td>
                    </tr>'
;
                               
$tag sizeof(array_keys($special)) > next(array_keys($special)) : $tag;
                               
$rep sizeof($special) > next($special) : $rep;                                    
            }
            
            
//finish it all off
            
$data .= '<tr><td><input value="submit" type="submit"></td></tr></table>'
            
            
//return it all
            
if($echo) { echo($data); }else{ return $data; }
        } 
TlcAndres is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design