Note that there are some explanatory texts on larger screens.

plurals
  1. POechoing in a form after submission
    text
    copied!<p>I have a form that send information to a mysql db. Error messages and a confirmation appear to the right of the form in a seperate div so the form action needs to send the user to the same page. I am echoing the field the user types in in case they need to edit something based on the error message that appears. However, if the form is submitted correct, how could i make it so the php does not echo in the form?</p> <pre><code>&lt;?php $submit = filter_input(INPUT_POST, 'submit'); //form data $fullname = filter_input(INPUT_POST, 'fullname'); $email = filter_input(INPUT_POST, 'email'); $business = filter_input(INPUT_POST, 'business'); $date = date("Y-m-d"); ?&gt; </code></pre> <p>then after other html code....</p> <pre><code> &lt;div class="wrap"&gt; &lt;div id="reg"&gt; &lt;form action='register.php' method='POST'&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; Your full name: &lt;/td&gt; &lt;td&gt; &lt;input type='text' name='fullname' value='&lt;?php echo $fullname;?&gt;'&gt; } &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Your email: &lt;/td&gt; &lt;td&gt; &lt;input type='text' name='email' value='&lt;?php echo $email;?&gt;'&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Your business: &lt;/td&gt; &lt;td&gt; &lt;input type='text' name='business' value='&lt;?php echo $business;?&gt;'&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/br&gt; &lt;input type='submit' name='submit' value='Register'&gt; &lt;/form&gt; &lt;/br&gt; &lt;/div&gt; &lt;?php if ($submit) { //open database $connect=mysql_connect("localhost","root","Ryweb1994"); mysql_select_db("phapsy"); //check for existence if($fullname&amp;&amp;$business&amp;&amp;$business) { $queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$email','$business','$date')"); echo ("&lt;div id='message'&gt;&lt;p&gt;You have been registered! We will send you an email with login information. Thank you for your interest in Phapsy!&lt;p&gt;&lt;/div&gt;"); } else echo "Please fill in &lt;b&gt;all&lt;/b&gt; fields!"; } ?&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
 

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