You are here: Re: php/html editing help « PHP Programming Language « IT news, forums, messages
Re: php/html editing help

Posted by David Gillen on 06/26/07 14:51

William Gill said:
> OK this may seem stupid, but I use this template for my php/html forms
> so that processing and form are in the same document.
>
> <?php if (array_key_exists('_submit_check',$_POST)) {
>
> php code to process form data and html to display a message
> to the user goes here.
> ...
> ...
>
> <?php } else { ?> // close if block, open else block
>
> html and form go here.
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> <input type="hidden" name="_submit_check" value="1"/>
> ...
> ...
>
> <?php } ?> // close else block
>
> In theory it's great, but after I get a whole lot of html in the gaps it
> gets really hard to follow and edit, especially if I'm editing months later.
>
> I tried indenting the html inserts, but as my php gets more involved,
> and properly indented (especially in the processing block) that gets
> pretty messy.
>
If you code is that long that you can't follow it easily you need to break it
down into various functions to handle what you are doing. Put these functions
into an include file.


<?php if (array_key_exists('_submit_check',$_POST)) {
processSubmission();
<?}else{?>
processNormal();
<?}?>

I'd also loose the comments about closing and opening blocks, they are
completely unnecessary.

D.
--
Fermat was right.

 

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

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