Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $Category = new Category($Conn);
- $categories = $Category->getAllCategories();
- // pass this data to categories.tpl template file
- $smarty->assign('categories',$categories);
- if($_POST){
- if(!$_POST['recipe_name']){
- $error = "Recipe name not set";
- }else if(!$_POST['recipe_instructions']){
- $error = "Recipe instructions not set";
- }else if(!isset($_FILES['recipe_image'])){
- $error = "Please upload a recipe image";
- }
- if($error){
- $smarty->assign('error', $error);
- }else{
- $random = substr(str_shuffle(MD5(microtime())), 0,10);
- $new_filename = $random.$_FILES['recipe_image']['name'];
- if(move_uploaded_file($_FILES["recipe_image"]["tmp_name"],__DIR__.'/../user_images/'.$new_filename)){
- $attempt = new Recipe($Conn);
- $attempt->addRecipe($_POST);
- if($attempt){
- $smarty->assign('success',"Your recipe has been added");
- }else{
- $smarty->assign('error',"An error occured.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement