HenintsoaHARINORO / ExoPHP

1 stars 1 forks source link

Mixing HTML with PHP not a good design. #1

Open Legion112 opened 3 years ago

Legion112 commented 3 years ago

Consider separating the PHP logic layer and presentation layer (HTML) into separate files. https://github.com/HenintsoaHARINORO/ExoPHP/blob/593d3864206c2c3d05cebd17f521cd5cf0ad1b7e/triangle.php#L53

There are patterns called MVC. It's about separating your business logic into a model, processing user requests into controllers (Working with global variables such as $_POST, $_GET), and the response representation into a separate file in your case its HTML.

Legion112 commented 3 years ago

Here some of the idea on how to do that https://github.com/HenintsoaHARINORO/ExoPHP/pull/2

Legion112 commented 3 years ago

@HenintsoaHARINORO Do you have any more questions or lack of understanding of my pull request? If not, I suggest merging it.

Legion112 commented 3 years ago

@HenintsoaHARINORO try to test your current pages about this vulnerability https://github.com/HenintsoaHARINORO/ExoPHP/issues/3. After try to refactor all your pages to use twig as you can see here https://github.com/HenintsoaHARINORO/ExoPHP/blob/7f4571b302bc5db909f12d923507d5d28f39de48/index.php#L19

HenintsoaHARINORO commented 3 years ago

I have to learn about MVC first then

Legion112 commented 3 years ago

@HenintsoaHARINORO I will close the issue by myself when there will be no mixing of PHP and HTML

Legion112 commented 3 years ago

@HenintsoaHARINORO refactor it to use twig https://github.com/HenintsoaHARINORO/ExoPHP/blob/main/triangle.php https://github.com/HenintsoaHARINORO/ExoPHP/blob/main/multiplication.php