You are here: php form code best practise « All PHP « IT news, forums, messages
php form code best practise

Posted by Barry Morris on 03/10/06 19:58

Hi

I am a php newbie although I have been a programmer for years, this can be
dangerous because all the languages I know use = as equal comparison so it
took me a long time to debug if ($STRING = 'fred') { not realising I was
assigning fred to $STRING and the evaluation is always true! It took ages to
discover if ($STRING = = 'fred') {.

I eventually managed to create a validated form which re-displays with an
error list, but I have a few questions about 'best practise' programming
because my solutions seem a little clumsy:

Combobox selection: How do you set a default or remember what the user
selected so the form is re-displayed with their selection. I did this: Item1
= '< -- Select a Country --> as "selected", I then changed the text to the
actual selection using echo if the form is re-displayed, Question: How do
you dynamically set a default or dynamically move the SELECTED tag?

<option selected><?echo $COUNTRY?></option>
<option>Afghanistan</option>
<option>Albania</option>
<option>Algeria</option>


Radio Buttons: I assigned each with a <? echoDEFAULT1 ?>, <? echo DEFAULT2
?> etc and set each to "" except for the default I really want, this is set
to "checked", surely I am not doing this the right way?


<input type="radio" value="MSWORD" <?echo $CKWORD?> name="RB1"
tabindex="14">Microsoft Word<br>
<input type="radio" value="TXT" <?echo $CKTXT?> name="RB1"
tabindex="15">Text File<br>
<input type="radio" value="PDF" <?echo $CKPDF?> name="RB1"
tabindex="16">Portable Document Format (PDF)</td>

TIA

Barry

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация