Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree with @Fosco. I want to explain a little bit more-</p> <p>There may be two cases- 1. You are doing raw php 2. You are coding on any php framework like CI or your own.</p> <p>and this will help to identify error field and change style to make better user response. Also last input data remain as it was.</p> <ol> <li><p>You are doing raw php In this case you can receive the input data in same file/page. I will do a common example later.</p></li> <li><p>You are coding on any php framework like CI or your own. In this case you load a view file to show the form page and you can pass data to view page/file when you load it.</p></li> </ol> <p>For both of above case you can do some coding like-</p> <pre><code>/* your input validation and verification goes here. where $error is generated too In addition add some error status in above section, you can do it in your $error array too. Also you store received data into $data here. index of $data should be similar as (corresponding) HTML input name. You can do it like below */ $error_stat = array(); //if the input field name is "email" and email input data raises any error then $error_stat['email'] = true; // same for name $error_stat['name'] = true; // and so on // now decide whether you will back to the form page or send the email and do other tasks if(count($error_stat)&lt;= 0){ // send email // do aditional tasks } else{ // load the form again if its aframework or the form is in seperate file // off course send $error,$data and $error_stat to the form page/file } // now here is a code segment of form page &lt;?php if(isset($error) &amp;&amp; count($error)&gt;0):?&gt; &lt;div id="error-msg"&gt; &lt;?php //display errors here ?&gt; &lt;/div&gt; &lt;?php endif;?&gt; &lt;form .... &gt; &lt;input type="text" name="email" class="&lt;?php echo (isset($error_stat['email'])?'error':'else'); ?&gt;" value="&lt;?php echo $data['email'];?&gt;" /&gt;\ &lt;!-- and so on ... --&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