jeudi 20 juillet 2017

Multiple variables and cookies with some if/else conditions in PHP

I have a page with many lines which all look slimier, in a manner of this example code:

<?php 
if(isset($_COOKIE["001"])){$var001 = $_COOKIE["001"]; $var001 = $_COOKIE["001"];}else {$var001 = '';}
if(isset($_COOKIE["002"])){$var002 = $_COOKIE["002"]; $var002 = $_COOKIE["002"];}else {$var002 = '';}
?>

basically, form data stored in cookies, cookies used like here to create variables which are used with some modifications to be used to export a document file..

Sometimes I have a feeling that what i'm doing is a terribly wrong and I'm not sure about if this is the right way to code in 2017...

I was thinking about using loops and arrays but I'm not sure how to do it correctly with this app.

Is this method is wrong? would I so something else, like learn OOP for it?

Aucun commentaire:

Enregistrer un commentaire