Note that there are some explanatory texts on larger screens.

plurals
  1. POSave button: how to update another table with results?
    primarykey
    data
    text
    <p>I have a table of recipes and there is a save button next to each recipe. When this is clicked, I would like the recipe name to be retrieved and saved to the user's profile (add to database).</p> <p>However, I am encountering some problems. I have a save button and this is linked to 'save_recipe.php'. Currently when I select save, I am being directed to a blank page. I have a feeling it is something to do with the way I have created the save button, as no echo statements are being displayed.</p> <p>The code for the button is:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="../user profile/save_recipe.php" method="post"&gt; &lt;input type="submit" name="submit" class="btn" value="Save Recipe"&gt;&lt;/td&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The code for save_recipe is:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;title&gt;BMI Result&lt;/title&gt; &lt;/head&gt; &lt;link rel="stylesheet" href="css.css" type="text/css" /&gt; &lt;body&gt; &lt;?php error_reporting(E_ALL &amp;~ E_NOTICE); // Start the session session_start(); // If the session vars aren't set, try to set them with a cookie if (!isset($_SESSION['user_id'])) { if (isset($_COOKIE['user_id']) &amp;&amp; isset($_COOKIE['username'])) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['username'] = $_COOKIE['username']; } } echo gfgfg; // Make sure the browser is transmitting in UTF-8 header('Content-type: text/html; charset=utf-8'); // Clear the error message $error_msg = ""; //if (isset($_SESSION['user_id'])) // echo $_SESSION['user_id']; $dbc = mysqli_connect('localhost', 'root', 'root', 'help_me_be_healthy') or die("Error " . mysqli_error($dbc)); mysqli_set_charset($dbc, "utf8"); echo gfdgfdg; if(isset($_POST['submit'])) { $recipe_name = mysqli_result(mysqli_query("SELECT `recipe_1_name`, `recipe_2_name` FROM `carbohydrates`"); //"SELECT `recipe_1_name` OR `recipe_2_name` FROM `carbohydrates` WHERE `user_id` = '" . $_SESSION['user_id'] . "'"; $query = "UPDATE `users` SET `recipes_saved` = $recipe_name WHERE `user_id` = '" . $_SESSION['user_id'] . "'"; $data= mysqli_query($dbc,$query); echo '$recipe_name'; ); } ?&gt; </code></pre> <p>Any advice would be much appreciated, I'm fairly new to this!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload