Ich wollte euch mal fragen was Ihr von dem Stil der Programmierung haltet. Bitte nehmt mich nicht auseinander
Mein Mini-Template-Versuchssystem:
auszug aus userdata.tpl
==========================================
<tr>
<td>Name</td>
<td><input type='Text' name='name' value='[NAME]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Vorname</td>
<td><input type='Text' name='vorname' value='[VORNAME]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Strasse</td>
<td><input type='Text' name='strasse' value='[STRASSE]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Ort / Stadt</td>
<td><input type='Text' name='ort' value='[ORT]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Postleitzahl</td>
<td><input type='Text' name='plz' value='[POSTLEITZAHL]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Lizenznummer / Vermittlernummer</td>
<td><input type='Text' name='lizenz' value='[LIZENZNUMMER]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Email-Adresse</td>
<td><input type='Text' name='email' value='[EMAIL]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Passwort(Verschlüsselt)</td>
<td><input type='Text' name='passwd' value='[PASSWORT]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Telefonnummer</td>
<td><input type='Text' name='telefon' value='[TELEFON]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Faxnummer</td>
<td><input type='Text' name='fax' value='[FAX]' class="[TEXTFIELD]"></td>
</tr>
=================================================
und die funktion die die Platzhalter ersetzt:
Mein Mini-Template-Versuchssystem:
auszug aus userdata.tpl
==========================================
<tr>
<td>Name</td>
<td><input type='Text' name='name' value='[NAME]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Vorname</td>
<td><input type='Text' name='vorname' value='[VORNAME]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Strasse</td>
<td><input type='Text' name='strasse' value='[STRASSE]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Ort / Stadt</td>
<td><input type='Text' name='ort' value='[ORT]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Postleitzahl</td>
<td><input type='Text' name='plz' value='[POSTLEITZAHL]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Lizenznummer / Vermittlernummer</td>
<td><input type='Text' name='lizenz' value='[LIZENZNUMMER]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Email-Adresse</td>
<td><input type='Text' name='email' value='[EMAIL]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Passwort(Verschlüsselt)</td>
<td><input type='Text' name='passwd' value='[PASSWORT]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Telefonnummer</td>
<td><input type='Text' name='telefon' value='[TELEFON]' class="[TEXTFIELD]"></td>
</tr>
<tr>
<td>Faxnummer</td>
<td><input type='Text' name='fax' value='[FAX]' class="[TEXTFIELD]"></td>
</tr>
=================================================
und die funktion die die Platzhalter ersetzt:
PHP-Code:
function user_data()
{
require("settings.php");
$DB = new DB;
$DB->ConnectDB("$HOST","$USR_NAME","$PASSWD","$DBNAME");
$DB->Query("SELECT * FROM `table` WHERE login = '$u_name'");
$DB->FetchRow();
$DB1 = new DB;
$DB1->ConnectDB("$HOST","$USR_NAME","$PASSWD","$DBNAME");
$DB1->Query("SELECT * FROM `design`");
$DB1->FetchRow();
$filename = "./tmpl/userdata.tpl";
$varr1 = file_get_contents($filename);
$search = array( '[NAME]', '[VORNAME]', '[STRASSE]','[ORT]','[POSTLEITZAHL]','[LIZENZNUMMER]','[EMAIL]','[PASSWORT]','[TELEFON]','[FAX]','[USERTABLE_CLASS]','[TEXTFIELD]');
$replace = array($DB->result[1], $DB->result[2], $DB->result[3], $DB->result[4],$DB->result[5],$DB->result[7],$DB->result[8],'********',$DB->result[10],$DB->result[11],$DB1->result[0],$DB1->result[1]);
$neu = str_replace($search, $replace, $varr1);
print $neu;
$DB->CloseLink();
$DB1->CloseLink();
}
Kommentar