Note that there are some explanatory texts on larger screens.

plurals
  1. POHow To Blank The Page Before Submitting PHP Form To Same Page?
    primarykey
    data
    text
    <p>I'm trying to create an auto-response script for work which will display the form fields as required, such as <code>Name</code>, <code>Username</code>, and <code>Password</code>. Once I select Submit, I want the script to remove the form, and display the output with the corresponding response in its stead without having to post it to another page. Ultimately having a form.php and a result.php for each individual scenario that I want will be too cluttered, hence why I'm trying to accomplish this. Thus far for the form, I have:</p> <pre><code>&lt;form action="&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" method="post"&gt; &lt;table width="100%" cellpadding="10" cellspacing="0"&gt; &lt;tr&gt; &lt;td style="width:33%"&gt; &lt;/td&gt; &lt;td style="width:33%"&gt;&amp;nbsp;&lt;/td&gt; &lt;td style="width:33%"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" style="width:99%"&gt; &lt;label&gt;Name&lt;/label&gt;&lt;span class="req"&gt;*&lt;/span&gt; &lt;span id="reqName" style="color:Red;display:none;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt; &lt;input type="text" name="name"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" style="width:99%"&gt; &lt;label&gt;Username&lt;/label&gt;&lt;span class="req"&gt;*&lt;/span&gt; &lt;span id="reqProblem" style="color:Red;display:none;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt; &lt;input type="text" name="username"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" style="width:99%"&gt; &lt;label for="txtProblem"&gt;Password&lt;/label&gt;&lt;span class="req"&gt;*&lt;/span&gt; &lt;span id="reqProblem" style="color:Red;display:none;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt; &lt;input type="text" name="password"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" style="width:99%"&gt; &lt;br /&gt; &lt;input type="submit" name="submit" value="Submit"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>For the PHP I have:</p> <pre><code>&lt;?php if(isset($_POST['submit'])) { echo "&lt;h4&gt;Response&lt;/h4&gt;"; $username = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; echo "&lt;p&gt;Hello, $name &lt;br /&gt; Your Login Information is as follows: Username: $username Password: $password. &lt;/p&gt;"; } ?&gt; </code></pre> <p>So to sum up, I want to completely remove everything before the PHP <code>isset</code> and replace it with the corresponding result.</p>
    singulars
    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.
 

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