Note that there are some explanatory texts on larger screens.

plurals
  1. POvalidating dynamic text box content in PHP
    primarykey
    data
    text
    <p>I have this and works fine. But can someone tell me is there a SMARTER way to validate this?</p> <p>In the validation here, you may find that the <code>echo "&lt;form.......</code> is replicated thrice to make sure that the form content is also visible along side the validation message when the form is submitted. Im sure there is a more refined method of validating text box content without form being replicated multiple times.</p> <p>Also appreciate if some one can suggest me a method to retain the text box value after the form is being submitted. Usually when the form is submitted the value you enter disappears.</p> <p>Thanks</p> <pre><code>&lt;?php include ("../connection/index.php"); ?&gt; &lt;form method='post' action=''&gt; &lt;input type="submit" name="sendone" id="sendone" value="OneClick"&gt; &lt;/form&gt; &lt;?php if(isset($_POST['sendone'])) { echo "Hello"; echo "&lt;form method='post' action=''&gt;&lt;input type='text' name='txt1' id='txt1'&gt;&lt;input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'&gt;&lt;/form&gt;"; } if(isset($_POST['sendtwo'])) {if($_POST['txt1']=='') { echo "Hello"; echo "&lt;form method='post' action=''&gt;&lt;input type='text' name='txt1' id='txt1'&gt;&lt;input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'&gt;&lt;/form&gt;"; echo "Empty";} else { echo "Hello"; echo "&lt;form method='post' action=''&gt;&lt;input type='text' name='txt1' id='txt1'&gt;&lt;input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'&gt;&lt;/form&gt;"; echo "Hit success!"; }} ?&gt; </code></pre> <p><strong>EDIT</strong></p> <p>Concept</p> <pre><code> &lt;hard coded submit1 button&gt; &lt;dynamically create a text box with a submit2 button&gt; &lt;when submit2 is activated is should validate the text box content&gt; </code></pre> <p>When the validation happens both the vaidated message and the text box should be visible</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.
    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