Guest User

Untitled

a guest
Oct 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2. include "vendor/autoload.php"; // it is crap, I will explain it later.
  3. include "dao/ProductDao.php";
  4. // view
  5. $blade=new \eftec\bladeone\BladeOne(__DIR__."/view",__DIR__."/compile");
  6. $blade->setMode(\eftec\bladeone\BladeOne::MODE_DEBUG);
  7.  
  8. // persistence
  9. $db=new \eftec\DaoOne("localhost","root","abc.123","bladeonetut1");
  10. $db->connect();
  11.  
  12.  
  13. // this page is two stage:
  14. // stage one, the form is open as new
  15. // stage two, the form was open and somebody clicked on the button
  16.  
  17. // collecting information
  18. $button=@$_POST['frm_button'];
  19. //$product['idproduct']=null; // it is null because it's auto generated by the database. we don't need it yet.
  20. $product['name']=@$_POST['frm_name'];
  21. $product['price']=@$_POST['frm_price'];
  22.  
  23. if ($button) {
  24. // if the button was pressed
  25. $product['idproduct']=\BladeOneTut1\ProductDao::insert($product);
  26. $message="ok";
  27. } else {
  28. // if not, we do nothing special.
  29. $message="";
  30.  
  31. }
  32. echo $blade->run("product.insert",['product'=>$product]);
Add Comment
Please, Sign In to add comment