Created
October 16, 2018 03:23
-
-
Save jorgecc/8214d6da326cba83e001901a1302e101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment