Reply to Checkbox forms, php & mysql

Your name:

Reply:


Posted by elyob on 05/27/06 16:15

Okay, I'm about to add some checkboxes to a form, and then store the data in
a column on a MySQL database. Just wanted to know best practice, at the
moment I'm writing and thinking .. God that's ungly code ...

<input type="checkbox" name="delta" <?php if ($delta==1) { echo
"checked"; }?>> Delta<br>
<input type="checkbox" name="mastercard" <?php if ($mastercard==1) {
echo "checked"; }?>> Mastercard<br>
<input type="checkbox" name="solo" <?php if ($solo==1) { echo
"checked"; }?>> Solo<br>
<input type="checkbox" name="switch" <?php if ($switch==1) { echo
"checked"; }?>> Switch<br>
<input type="checkbox" name="visa" <?php if ($visa==1) { echo
"checked"; }?>> Visa<br>

MySQL database fields ...
delta binary(1) No 0
mastercard binary(1) No 0
solo binary(1) No 0
switch binary(1) No 0
visa binary(1) No 0

When I output the fields, I get "on" or empty, and am wondering whether I am
making a good decision to do the code this way. Now I need to figure out how
to update the database based on the forms output.

Thanks

[Back to original 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

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