Forums »
  Snippets forums topics about simple codes to make programming fun »
    Php Form Using Array For Field Name Template User Information

Php Form Using Array For Field Name Template User Information

Description: this is php form using array for field name template user information you can use
Tags: php ,code ,string ,programming
Posted On Fri Nov 23, 2007 By hostman In Snippets forums topics about simple codes to make programming fun Forums
i often use this form template when i want to create a new form


$num_fields = 18;

function tidy ($form_string) {
$form_string = trim(stripslashes($form_string));
return $form_string;
}
?>


$field_name = array(

1 => 'Company Name:(if any)',
2 => 'First Name',
3 => 'Last Name',
4 => 'Street',
5 => 'City',
6 => 'State/ Providence',
7 => 'Country',
8 => 'Zip/Postal Code',
9 => 'Phone',
10 => 'E-Mail',
11=> 'Confirm E-Mail',
12 => '

 

',
13 => 'Password',
14 => 'Confirm Password',
15=> 'Secret Question',
16 => 'Answer',
17 => 'Confirmation Key',
18 => 'Agree To Terms of Service'


);
$field_type = array(

1 => 'text',
2 => 'text',
3 => 'text',
4 => 'text',
5 => 'select',
6 => 'select',
7 => 'text',
8 => 'text',
9 => 'text',
10 => 'text',
11=> 'text',
12 => 'break',
13 => 'password',
14 => 'password',
15 => 'text',
16 => 'text',
17 => 'text',
18 => 'checkbox'
);


for($counter =1; $counter <= $num_fields ; $counter++)
{


echo '
'.$field_name[$counter].'
';

switch($field_type[$counter])
{
case 'textarea':
echo '';
break;

case 'checkbox':
echo '';
break;

case 'radiobutton':
echo '';
break;

case 'select':
echo'

';
break;

case 'file':
echo '';
break;

case 'hidden':
echo '';
break;

case 'break':

break;

default:
echo '';
break;
}



echo'
';

}
?>



// The data comes from the form in fig 4.2


if(isset($_REQUEST['Submit']))
{
foreach($_POST['user'] as $key => $line) {
$user = tidy($line);
print("n
User[" . $key . '] ' . $user);
}
}
?>
Dallas Sun Jan 25, 2009
this might be good for small sites, but you should really look at making it static html when you're planning on making a popular site.

often you're unsure whether the site will be popular or not, so it's best not to do things like the above.
Information
Title: Php Form Using Array For Field Name Template User Information
Info: This Post Has Been Viewed 0 Times Since
Date: Fri Nov 23, 2007
Author hostman Received 1 Replies #1375
Related Content
Related Pages
Related Sites
Add Your Website
Share
wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Tue Jun 18, 2013 (-8 GMT)
Powered by: Webune Forums V5