Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "vendor/autoload.php"; // it is crap, I will explain it later.
- include "dao/ProductDao.php";
- // view
- $blade=new \eftec\bladeone\BladeOne(__DIR__."/view",__DIR__."/compile");
- $blade->setMode(\eftec\bladeone\BladeOne::MODE_DEBUG);
- // persistence
- $db=new \eftec\DaoOne("localhost","root","abc.123","bladeonetut1");
- $db->connect();
- // this page is two stage:
- // stage one, the form is open as new
- // stage two, the form was open and somebody clicked on the button
- // collecting information
- $button=@$_POST['frm_button'];
- //$product['idproduct']=null; // it is null because it's auto generated by the database. we don't need it yet.
- $product['name']=@$_POST['frm_name'];
- $product['price']=@$_POST['frm_price'];
- if ($button) {
- // if the button was pressed
- $product['idproduct']=\BladeOneTut1\ProductDao::insert($product);
- $message="ok";
- } else {
- // if not, we do nothing special.
- $message="";
- }
- echo $blade->run("product.insert",['product'=>$product]);
Add Comment
Please, Sign In to add comment