Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST variable doesn't echo in function
    primarykey
    data
    text
    <p>I am currently learning the most basic PHP ever. I have 5 files.</p> <p>index.php:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Budget Calcule&lt;/title&gt; &lt;link href="style.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Put in your: - &lt;/h2&gt; &lt;form action="functions.php" method="post"&gt; &lt;h3&gt;Income&lt;/h3&gt; &lt;label&gt;Salary: &lt;input name="salary" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;h3&gt;Outgoings&lt;/h3&gt; &lt;label&gt;Living: &lt;input name="living" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Insurance: &lt;input name="insurance" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Communication: &lt;input name="communication" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Loan: &lt;input name="loan" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Food &amp; Drink: &lt;input name="foodAndDrink" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Entertaintment / Shopping: &lt;input name="entertainmentOrShopping" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Transport: &lt;input name="transport" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;label&gt;Other: &lt;input name="other" type="text" /&gt;&lt;/label&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>this is my functions.php:</p> <pre><code>&lt;?php include('variables.php'); if(!($_POST['Submit'])){ if(isset($_POST['salary'])){ header('Location: output.php'); return $_POST['lon']; }else{ echo "All fields are required"; } } ?&gt; </code></pre> <p>this is my variables.php:</p> <pre><code>&lt;?php $salary= $_POST['salary']; $living= $_POST['living']; $insurance= $_POST['insurance']; $communication = $_POST['communication']; $loan = $_POST['loan']; $food = $_POST['food']; $entertaintmentOrShopping = $_POST['entertaintmentOrShopping']; $transport = $_POST['transport']; $other= $_POST['other']; ?&gt; </code></pre> <p>this is my output.php file:</p> <pre><code>&lt;?php include('outputFunction.php'); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Output.php&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php myText(); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and last but not least, this is my outputFunction.php file:</p> <pre><code>&lt;?php include('variables.php'); function myText(){ echo "Your salary per month is: " . $_POST['salary']; } ?&gt; </code></pre> <p>Now you're thinking "why have he split up his code in different files?" Well first of all, I split the variables from functions.php because I wanted outputFunctions.php to get the variables from variables.php so i could echo my `$_POST['salary']; . The function myText(); outputs the text just fine, but it doesnt output the $_POST['salary'];.</p> <p>I do not know why it doesnt work, I just wonder if you could be my extra eyes and see if I've done some mistake.</p> <p>PS! Don't down vote my question just because you think it's stupid. I am having problem with this issue and been working on it for hours without advancing anywhere.</p>
    singulars
    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