[thelist] PHP/html form queston: a better way to do this form and submission?

John Corry lists at neoncowboy.com
Thu Aug 11 11:04:20 CDT 2005


$error_codes = array(
	'home_phone_number'=>'Home Phone Number'
	, 'area_code' => 'Area Code'
	, etc => etc
);

If(error())
{
	echo 'You didn't enter your " .$error_codes[$_POST['field_name'];
}

Use an array to map the plain text error codes to the form field names they
correspond to.

John

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org 
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Bruce Gilbert
> Sent: Thursday, August 11, 2005 11:49 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] PHP/html form queston: a better way to do 
> this form and submission?
> 
> Hello,
> 
> I am working on a form which uses PHP to submit the info. to 
> an email address. For an instance like a phone number I  have 
> the html mark-up like this:
> 
> <td colspan="2"><label for="home_phone_number">Home Phone 
> Number:</label><br> <input
>                         class="textbox" maxlength="6" size="6"
> name="area_code" id="area_code" value="{$_POST['area_code']}"> &nbsp;
>                     <input 
>                         class="textbox" maxlength="6" size="6"
> name="3_digit_exchange" id="3_digit_exchange"
> value="{$_POST[3_digit_exchange]}" > &nbsp;
>                     <input 
>                         class="textbox" maxlength="10" size="10"
> name="last_four_digits" id="last_four_digits"
> value="{$_POST['last_4_digits']}"> &nbsp;
>                   </td>
> 
> with different input values for the area code, 3 digit 
> exchange and last 4 digits. and then you check the values of 
> each and post either the results or an error.
> 
> Posting 'You didn't enter your " .$fieldname " might be 
> confusing if the fieldname is "last_four_digits" so, I was 
> hoping of a more simplified way to do this type of 
> information in my form.
> 
> Also is there a way for the form to automatically go to the 
> next field once a certain amount of info. has been entered? 
> eg: after putting in
> 3 digits for the area code, the cursor will automatically 
> jump to the next field?
> 
> thanks!!!
> 
> --
> ::Bruce::
> -- 
> 
> * * Please support the community that supports you.  * * 
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip 
> Harvester and archives of thelist go to: 
> http://lists.evolt.org Workers of the Web, evolt ! 
> 




More information about the thelist mailing list