Jump to content

stacanovist

New Members
  • Posts

    7
  • Joined

  • Last visited

stacanovist's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. CUT Hi Adam Thanks you for taking time to look at the code. The instructions were to make a "easy-readable-code" php-app. So I thought using a framework was not a good choise (this is how I interpreted it). Of course I had used it if I could. Yes, I oonly now realized about using POST vars in login.php without checking them. Strange, I normally have some code like: $username = isset($_POST['username']) ? $_POST['username'] : ''; I missed that. Yes. I think in other scripts I have that kind of control. Anyway, the posted vars are at least escaped when querying DB. About process_employee. Well, I dislike code repetition. There are maybe better ways to do it. But I dont like to fetch the same variables twice in two different scripts. As they do more or less the same thing. A part from either creating or editing the user. The $db variable (and the same applies for $admin variable) are created in bootstrap.php. All the script-controllers (or all the pages should I say) includes boortstrap at the top of the script. As $db is always used by all the scripts (you always need to query DB in these scripts) I thought it was the best place to put it in. $admin is also created in bootstrap. All the pages (almost all of them) need to verify that the admin has logged in. So even for $admin I thought the best place was in bootstrap. Where would you have put Database class? In some core dir? I didnt understand what you meant about indentation in models. I think it is allright. The bootstrap instantiates everything because more or less al the pages use all the instances. I included jquery, even if I only used it once, just to show the style I use when having javascript/jquery. There was not much more to use it for. But I prefered to use it anyway to make them underrstand I know how to use it.
  2. PS: I didnt use a framework because I was unsure how they would consider that. I tought it could be a good idea to make my own tiny framework just to show them I know the basic concept of building an mvc. Not using a real single controller instead of a controller for each requested page is probably not a great idea. Im aware of it. PS2: it seems the file has not been attached?? Seems wont accept rar files. I uploaded the file here: http://memnotic.com/phpfreaks.rar
  3. Hi Gizmola Well, they didnt specify how I should solve it. Only told me it should be easy to read the code and that I should use best practices for php, js, html and css. After I read all the answers I understand that there is big risk he is using my code for free. This was the first and last time I will make this kind of tests. Anyway, regarding how experienced I am with coding it would still be very helpful if somebody with a lot of experience would give a look at the code and give some feedback. I would really appreciate it. I will attach the rar file and hope you (and maybe somebody else) can give me some feedback. Thanks a lot.
  4. Let me ask you guys: Would you never do an application for a company that is going to recruit a programmer? I mean, doing an app to show them you level as programmer? If they say: "we are looking for a php-developer, but we require him to do a test so we can understand if he has a good level as programmer". You would say: no?? or you would say: "Yes but you have to pay me for that"?
  5. Ok. Lets pretend they were not interested in getting work done for free. Whats bad with the code i wrote, from the description I wrote?
  6. Ok, I understand. People that would look at my code are doing me a favor. So ask them to also download the code maybe is too much. So I will do my best to explain what this is about and put some code sample. Preface: Someone asked me to make a test. He was looking for a real php-expert. I have many years experience in PHP. And I think I am good enough. The test was about doing a simple PHP-application, with js/css/html, for managing employers. When I sent the zip package with the code, after he reviewed it, he said that its not enough. He needs someone very experienced. Yes, Im very angry, even because he didnt tell me what part of the code makes him understand/think Im not enough experienced. Yes, I need to learn more, like everybody. But it would be a good idea to know what part of the code is not considered qualitative. I tried to make something similar to Codeigniter. The head folder contains the subfodlers: app, database, logs, www In app there are the folders models and views. And also the folder config, containing environment.php and bootstrap.php. In app/models there are the classes: Admin.php (to handle admin login, the admin needs to manage employees), Database.php (which basically has the method connect and the mysql->close in the destructor.), the class Employee itself, with all the crud methods, and Logger which contains the static method for writing to log folder. In app/views there are the index.php for showing html for the login. The home.php for listing the employees. Then there is employee_form which is used both for creating and editing an employee. Depending on the params sent to this view, it will customize messages for whether its about editing or creating. The last view is layout. In the middle it includes the view file itself (index, home or employee_form). The head folder "database" only contains the schema for the DB. Im using indexes for all the fields that can be in where or order by. In www there are index (which includes the view index), home (which includes the view home), newemploye and editemploye. Yes, there is no controller folder. There is the risk for repeating code. But I was not really sure about having an htaccess to redirect every request to a single index, which in turn should select the controller. But I think its quite ok. Then a page like www/home.php looks something like this: <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/config/config.php'); require_once(APP_PATH . '/config/bootstrap.php'); $employee = new Employee($db); $all_employees = $employee->get_all(); $view_name = 'home'; require_once(APP_PATH . '/views/layout.php'); In bootstrap the db-instance is created. COnnection to it is made. And reference to db is passssed to the Employee-class (so it can use mysql). Im using things that are considered important to make good and secure code. Im omitting the closing php-tag. Im escaping all the strings with real_escape_string(Im using mysqli). Im printing all the GET/POST and data from DB using htmlspecialchars. Im logging errors to the customized Logger class. Im using an home made FlashMessages for printing messages on the page. Guys, I hope you read until here. Im aware that you never end learning new things. But I have alot of experience. This guy says Im not experienced enough. I want to know why. I want to improve my coding skills. What do you think?
  7. Hi everybody Just signed up at this site. I dont really know if this is the right section, but anyway. I would like to ask to people that consider themselves as php experts what they think of a quite little application I have written I wrote and that is considered (by the one that commissioned it) not at a very good level or not as good as an expert would write it. Is this the right place to post it? I dont know if it is possible to attacch zip files. And if there will be someone interested in looking at it. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.