" " && isset($_SESSION['sessionUserID'])){ $sql = "INSERT INTO recipes ( accept_rules, Brief, User_ID, Recipe_Name, Prep_Time_Hours, Prep_Time_Minutes, Total_Time_Hours, Total_Time_Minutes, Serving_Size, Category, Instructions, Share ) VALUES ('" . $_REQUEST['accept'] . "', '" . ereg_replace("'","´",$_REQUEST['Brief']) . "', '" . $_SESSION['sessionUserID'] . "' , '" . ereg_replace("'","´",$_REQUEST['Recipe_Name']) . "' , '" . $_REQUEST['Prep_Time_Hours'] . "' , '" . $_REQUEST['Prep_Time_Minutes'] . "' , '" . $_REQUEST['Total_Time_Hours'] . "' , '" . $_REQUEST['Total_Time_Minutes'] . "' , '" . $_REQUEST['Serving_Size'] . "' , '" . $_REQUEST['Category'] . "' , '" . ereg_replace("'","´",$_REQUEST['Instructions']) . "', '" . $_REQUEST['Share'] . "' )"; $result = mysql_query($sql) or die(mysql_error()); //get id just inserted $recipeId = mysql_insert_id(); //insert recipe into mycookbook $sqlR = "INSERT INTO cookbook (User_ID, Recipe_ID) VALUES ('" . $_SESSION['sessionUserID'] . "', '$recipeId')"; $result = mysql_query($sqlR) or die(mysql_error()); //insert sub cats $count = count( $_REQUEST["subCatId"] ); $sessUserID = $_SESSION['sessionUserID']; for ($i=0; $i<$count; $i++) { //insert into ingredients table if($_REQUEST["subCatId"][$i] > " "){ $subCatID = $_REQUEST["subCatId"][$i]; $sqlR = "INSERT INTO recipes_recipes_sub_cat (recipe_ID, recipe_sub_cat_ID, user_ID ) VALUES ($recipeId, $subCatID, $sessUserID)"; $result = mysql_query($sqlR) or die(mysql_error()); }; }; // end of subcats //insert ingredients $count = count( $_REQUEST["Ingredient"] ); for ($i=0; $i<$count; $i++) { //insert into ingredients table if($_REQUEST["Ingredient"][$i] > " "){ $InsertStr = "INSERT INTO recipes_ingredients (Recipe_ID, Ingredient, Amount ) VALUES ('$recipeId', '" . ereg_replace("'","´",$_REQUEST["Ingredient"][$i]) . "', '" . ereg_replace("'","´",$_REQUEST["Amount"][$i]) . "')"; $result = mysql_query($InsertStr) or die(mysql_error()); }; }; //*************************************************** //insert recipe photo //*************************************************** if( $_FILES['Photo']['name'] > " ") { //make sure this directory is writable! $path_thumbs = "recipePhotos/"; //the new width of the resized image, in pixels. $img_thumb_width = 362; // $extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed) //List of allowed extensions if extlimit = yes $limitedext = array(".gif",".jpg",".png",".jpeg"); //the image -> variables $file_type = $_FILES['Photo']['type']; $file_name = $_FILES['Photo']['name']; $file_size = $_FILES['Photo']['size']; $file_tmp = $_FILES['Photo']['tmp_name']; //check if you have selected a file. if(!is_uploaded_file($file_tmp)){ echo "Error: Please select a file to upload!.
--back"; exit(); //exit the script and don't process the rest of it! } //check the file's extension $ext = strrchr($file_name,'.'); $ext = strtolower($ext); //uh-oh! the file extension is not allowed! if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { echo "Wrong file extension.
--back"; exit(); } //so, whats the file's extension? $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; //create a random file name // $rand_name = md5(time()); // $rand_name= rand(0,999999999); $rand_name = $recipeId . "_" . $_SESSION['sessionUserID']."_".time(); ; //the new width variable $ThumbWidth = $img_thumb_width; ///////////////////////////////// // CREATE THE THUMBNAIL // //////////////////////////////// //keep image type if($file_size){ if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){ $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } //list the width and height and keep the height ratio. list($width, $height) = getimagesize($file_tmp); //calculate the image ratio $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; }else{ $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //make sure the image is big enough to resize if (($newwidth > $width) || ($newheight > $height) ){ $newwidth = $width; $newheight = $height; } //function for resize image. if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } //the resizing is going on here! imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //finally, save the image ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); $pictureName= $rand_name.".".$file_ext ; ImageDestroy ($resized_img); ImageDestroy ($new_img); } //now create smaller thumb **------ //// //*************************************************** //insert recipe photo //*************************************************** //make sure this directory is writable! $path_thumbs = "recipePhotos/thumbs"; //the new width of the resized image, in pixels. $img_thumb_width = 80; // $extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed) //List of allowed extensions if extlimit = yes $limitedext = array(".gif",".jpg",".png",".jpeg"); //the image -> variables $file_type = $_FILES['Photo']['type']; $file_name = $_FILES['Photo']['name']; $file_size = $_FILES['Photo']['size']; $file_tmp = $_FILES['Photo']['tmp_name']; //check if you have selected a file. if(!is_uploaded_file($file_tmp)){ echo "Error: Please select a file to upload!.
--back"; exit(); //exit the script and don't process the rest of it! } //check the file's extension $ext = strrchr($file_name,'.'); $ext = strtolower($ext); //uh-oh! the file extension is not allowed! if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { echo "Wrong file extension.
--back"; exit(); } //so, whats the file's extension? $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; //create a random file name // $rand_name = md5(time()); // $rand_name= rand(0,999999999); // // $rand_name = $recipeId . "-" . $_SESSION['sessionUserID'] ; //the new width variable $ThumbWidth = $img_thumb_width; ///////////////////////////////// // CREATE THE THUMBNAIL // //////////////////////////////// //keep image type if($file_size){ if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){ $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } //list the width and height and keep the height ratio. list($width, $height) = getimagesize($file_tmp); //calculate the image ratio $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; }else{ $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //make sure the image is big enough to resize if (($newwidth > $width) || ($newheight > $height) ){ $newwidth = $width; $newheight = $height; } //function for resize image. if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } //the resizing is going on here! imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //finally, save the image ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); } $sql = "UPDATE recipes set Photo = '$pictureName' where ID = '$recipeId'"; $result5 = mysql_query($sql) or die(mysql_error()); } header("Location: myCookbookConfirm.php"); exit ; } //end of recipe insert ?> Yada Home | Cookbook
yada home
my fridge

+ Back to Cookbook Browse YadaHome Recipes

Add A Recipe
Recipe Name: A value is required.
Brief Description:
Prep Time: hr min
Total Time: hr min
Serving Size:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Ingredient: Amount:
Instructions:
A value is required.
 
Select a category:
Select sub categories:
Add Photo [optional] :
(.gif , .jpg ,.png or.jpeg)
Share Recipe with other YadaHome Members

  

 

$myrow["recipes_cat_ID"]){ $holdID = $myrow["recipes_cat_ID"]; if ($counter > 0){ echo "";} echo "\n"; ?>

 
 
free profile