Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>What <a href="http://www.w3schools.com/php/php_forms.asp" rel="nofollow noreferrer">W3Schools (PHP Form Handling)</a> fail to mention is</strong>, that the entire (2) bodies of code need to either be inside a single file, or in 2 seperate files in order for it to work as expected.</p> <p>However, the code from W3Schools and the OP are not indentical and have been modified, using <code>htmlspecialchars</code> and <code>(int)</code></p> <p>If you wish to make use of <code>htmlspecialchars</code>, do the following in your <code>welcome.php</code> file:</p> <pre><code>&lt;?php $fname = htmlspecialchars($fname); ?&gt; Welcome &lt;?php echo $_POST["fname"]; ?&gt;!&lt;br&gt; You are &lt;?php echo (int)$_POST['age']; ?&gt; years old. </code></pre> <h2>Form used:</h2> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="welcome.php" method="post"&gt; Name: &lt;input type="text" name="fname"&gt; Age: &lt;input type="text" name="age"&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I did not see any mention on the W3Schools website about the use of <code>htmlspecialchars</code> or <code>(int)</code></p> <pre><code>Hi &lt;?php echo htmlspecialchars($_POST['name']); ?&gt;. You are &lt;?php echo (int)$_POST['age']; ?&gt; years old. </code></pre> <p>If you wish to make use of <a href="http://php.net/manual/en/function.htmlspecialchars.php" rel="nofollow noreferrer"><strong>htmlspecialchars</strong></a> then you should the following syntax:<br> <code>$fname = htmlspecialchars( $fname );</code> And placed within <code>&lt;?php</code> and <code>?&gt;</code> tags such as:</p> <pre><code>&lt;?php $fname = htmlspecialchars( $fname ); ?&gt; </code></pre> <p><strong>NOTE</strong>: I know next to nothing about running a Webserver from my own computer, yet from information I found <a href="https://stackoverflow.com/a/312886/1415724"><strong>here on SO</strong></a> mention that in order to access your PHP files, you need to type in <code>http://localhost</code> in your Web browser's address bar and the folder where your file is in.</p> <hr> <p>Please visit <a href="https://stackoverflow.com/a/312886/1415724"><strong>this answer</strong></a></p> <p>StackOverflow did not let me insert the codes on that page, for one reason or another.</p>
 

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