Piszę sobie taki skrypt mailingowy i zastanawiam się jak tu zopytmalizować wyświetlanie HTML'a. Chodzi o to że PHP kontroluje dane w prowadzane przez użytkownika i wyświetla odpowiedni komunikat po wysłaniu formularza. Ale wydaje mi się że rozwiązanie które zastosowałem nie jest zbyt profesjonale i optymalne.
Proszę was o podpowiedzi.

Przy okazji, jak oceniacie napisany przezemnie kod?
<?php $formtresc = " <style type='text/css'> input{ display: block; } </style> <div form-wrapper style='width: 400px; height: 500px; margin: 0 auto;'> <center> <form action='mail.php' method='get'> <div class='error' id='imie'></div> Your name: <input type='text' name='imie' /> <div class='error' id='email'></div> Your e-mail: <input type='text' name='email' /> Select subject of your message: <div class='error' id='temat'></div> <select name='subject'> <option>Default</option> <option>Bug report</option> <option>Grats</option> </select></br> Your message: <textarea name='message' cols='50' rows='10'></textarea></br></br> <input type='submit' name='send' value='Dalej'/> </form> </center> </div> "; $formtrescE1 = "<form action='mail.php' method='get'> <div class='error' id='imie'>Podaj imie!</div> <input type='text' name='imie' /></br> <div class='error' id='email'></div> <input type='text' name='email' /> <div class='error' id='temat'></div> <select name='subject'> <option>Default</option> <option>Bug report</option> <option>Grats</option> </select> <textarea name='message' cols='50' rows='10'>Tresc wiadomosci</textarea> <input type='submit' value='Dalej'/> </form>"; $formtrescE2 = "<form action='mail.php' method='get'> <div class='error' id='imie'></div> <input type='text' name='imie' /></br> <div class='error' id='email'>Podaj email</div> <input type='text' name='email' /> <div class='error' id='temat'></div> <select name='subject'> <option>Default</option> <option>Bug report</option> <option>Grats</option> </select> <textarea name='message' cols='50' rows='10'>Tresc wiadomosci</textarea> <input type='submit' value='Dalej'/> </form>"; $formtrescE3 = "<form action='mail.php' method='get'> <div class='error' id='imie'></div> <input type='text' name='imie' /></br> <div class='error' id='email'></div> <input type='text' name='email' /> <div class='error' id='temat'>Podaj temat wiadomosci</div> <select name='subject'> <option>Default</option> <option>Bug report</option> <option>Grats</option> </select> <textarea name='message' cols='50' rows='10'>Tresc wiadomosci</textarea> <input type='submit' value='Dalej'/> </form>"; $formtrescE4 = "<form action='mail.php' method='get'> <div class='error' id='imie'></div> <input type='text' name='imie' /></br> <div class='error' id='email'></div> <input type='text' name='email' /> <div class='error' id='temat'></div> <select name='subject'> <option>Default</option> <option>Bug report</option> <option>Grats</option> </select> <div class='error' id='message'>Podaj tresc wiadomosci</div> <textarea name='message' cols='50' rows='10'></textarea> <input type='submit' value='Dalej'/> </form>"; #--------------Temporary Settings--------# # error id: # 1 - brak imienia # 2 - brak emaila # 3 - nie wybrany temat # 4 - brak tresci maila #$_GET['error']['id'] = '4'; #-------------End of temp. settings------# #--------Configuration File Info---------# #--------------READ THIS!----------------# # # First Line: There you have an e-mail # address. Messages will be send to # that e-mail! # # Second Line: There you have color # of border of the inuts # # # # #-----End of conf. file info-------------# #-------------Functions------------------# function errorExist(){ #var_dump($a); #print_r($_GET); return $error; } function errorIdChecker(){ # funkcja zamiast 'echo' ma zwracac id bledu dla innej funkcji if ($_GET['error']['id'] == 1) { #echo 'brak imienia'; return 1; } elseif ($_GET['error']['id'] == 2) { #echo "brak emaila"; return 2; } elseif ($_GET['error']['id'] == 3) { #echo "brak tematu"; return 3; } elseif ($_GET['error']['id'] == 4) { #echo "wpisz tresc wiadomosci"; return 4; } } #END OF errorIdChecker function function makePage($errorID, $trescE1, $trescE2, $trescE3, $trescE4){ // wyswietlanie odpoiedniej tresci switch ($errorID) { case 1: break; case 2: break; case 3: break; case 4: break; default: break; }# Switch end } #END OF makePage function function catchError(){ $_GET['error']['id'] = 1; return; } if (empty($_GET['email']) or !preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_GET['email'])) { $_GET['error']['id'] = 2; return; } if ($_GET['subject'] == 'Default') { $_GET['error']['id'] = 3; return; } $_GET['error']['id'] = 4; return; } } function loadConfigFile(){ $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; if (!$file) { exit; } else { #print_r($config); } } return $config; } #var_dump($errorE); catchError(); $errorE = errorExist(); //sprawdzanie czy przy ladowaniu strony jest jakis error $errorE = false/true if ($errorE == true) { $errorId = errorIdChecker(); makePage($errorId, $formtrescE1, $formtrescE2, $formtrescE3, $formtrescE4); #print_r($a); } else{ $configf = loadConfigFile(); $message = $_GET['message']." Author e-mail addres: ".$_GET['email']; } } else { #echo $_SERVER['DOCUMENT_ROOT']; } // Imie // kategoria // tresc // dodawanie wyrazow/liczb ?>