Nicol-tjee / educom-webshop-basis-1699355222

0 stars 0 forks source link

Haal de velden voor $email, $phone, $street, $strnr, $zpcd en $resid maar 1x uit de POST data #17

Open JeroenHeemskerk opened 10 months ago

JeroenHeemskerk commented 10 months ago

In de code hieronder https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L69-L170

Zie ik heel veel keer staan iets als: $veld = $_POST['veldnaam']; zoals bijvoorbeeld voor het telefoonnummer 9x hieronder: https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L72 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L83 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L93 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L119 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L139 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L146 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L153 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L160 https://github.com/Nicol-tjee/educom-webshop-basis-1699355222/blob/e083d861185dcd8945c1fd3bc78e48d4b607adcf/contact.php#L164 Dit is niet volgens het Don't Repeat Yourself (D.R.Y) principe

Zorg dat elk veld er maar 1x wordt uitgehaald:

if (empty($_POST["phonenumber"])) { 
     if ($com =="Phone") {                                      
         $phoneErr = "Telefoonnummer is verplicht"; 
     } else if ($pstIncomplete) {
         $phoneErr =  "Uw adresgegevens zijn niet volledig";
     }
} else {
     $phone = $_POST['phonenumber'];
} 
Nicol-tjee commented 10 months ago

Ik heb dit inmiddels al aangepast in een andere opdracht.