Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by benanamen

  1. 1. Stop with the random use of curly braces. Just use them always. 2. Get rid of the redundant submit check. You should be checking the REQUEST METHOD anyways. Checking for submit can fail in certain cases. 3. Stop creating variables for nothing. 4. The errors should go in an errors array. 5. Your code gives a success message for submitting an empty form. That makes no sense. 6. There is nothing that stops the DB insert since you do nothing with the errors.
  2. Op, tell us what the real problem is you are trying to solve with this rather than asking about your attempted solution to the problem. What is the high level overview of what you have going on?
  3. The manual is always a good place to start.
  4. That's what prepared statements are for. Although, you would VALIDATE the data.
  5. @gingerjm, it is part of PRG. Post, Redirect, Get
  6. Lets just move on. Yeah, OP, I noticed something funny going on with the posts and timing of edits/deletes. It was something beyond us which made things confusing for both (all) of us.
  7. It wasn't "baseless" until you deleted your post after I posted, thus derailing the continuity of the thread. Great job solving the problem yourself though. 😀
  8. Your second post has absolutely nothing to do with your first post. You really should have created a new thread. A simple google search on using LIKE would have easily answered your question. I guess you didn't read the page I posted the link to.
  9. I would encourage you to continue to learn. As you get better you will recognize that tutorials such as the one you followed was very poorly done.
  10. Yeah, the question smells. OP tell us what the real problem is you are trying to solve instead of asking about your attempted solution to solving it.
  11. I would suggest you take some time to get down on SOLID principles. Here are a couple links. (I didn't read these pages. There may be better links) https://medium.com/prod-io/solid-principles-takeaways-ec0825a07247 https://www.hashbangcode.com/article/solid-principles-php
  12. There is much that could be said about this code, but to keep on point, you need to use Dependency Injection and pass an instance of the helper class to your user class just like you did with the PDO connection. * The duplicate query should be one of the first clues of a problem with this class. This pretty much explains what I see here so the current state of the code makes sense for now. You should eventually end up with quite a bit of refactoring when you get it dialed in.
  13. What have you tried besides posting this on every coding forum?
  14. The first problem is that you are using variables in your query. You need to use Prepared Statements. You have not shown us where $check1_res comes from.
  15. Your right. It "doesn't work".
  16. Truncate the table. It will also delete all the data. TRUNCATE TABLE table_name; TRUNCATE TABLE table_name;
  17. Allow me to direct you to the PHP Manual. It gives you an exact example of what you are asking. https://www.php.net/manual/en/function.error-log.php
  18. In HTML5, the "action" is not necessary at all when submitting to the same page. You can simple do like so... <form method="post">
  19. The one thing that hasn't been mentioned is WHY would YOU want to do this in the first place?
  20. The last part could use some cleanup. if (mysqli_num_rows($result)) { return $result; } return false;
  21. OP, What is the point of adding another layer (Javascript) just to get a random value? Why not just generate in Php? And rather than tell us about your attempted solution to the real problem, how about tell us what the real problem is.
  22. All of this... $category = $_POST['category']; $item_type = $_POST['item_type']; $item_size = $_POST['item_size']; $product_name = $_POST['product_name']; $item_qty = $_POST['item_qty']; $price = $_POST['price']; $total_price = $_POST['total_price']; $item_price = $_POST['item_price'];
  23. Get rid of the variables for nothing. You already have the POST values, just use them.
  • 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.