Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    155
    Thanks
    34
    Thanked 1 Time in 1 Post

    value for textbox doesn't retain on refresh

    When a user submits my form and say he doesn't do the captcha right.. all my form fields retain their data except for the Comments which happens to be a textbox vs. a text input. Not sure why that is but I can't find a solution. Thanks for any help. I've tried many variations of the echo 'ing of it back.

    PHP Code:
    <form method="post">
          <table width="728" height="277" border="6" align="center"><tbody style="font-size: 12px;"><tr><td width="554"><blockquote>
                <p><font color=red>*</font>Name<br/>
                  <span id="sprytextfield1">
                    <input type ="text" name="Name" maxlength="30" value="<?php  echo $_POST['Name'];?>" /> <br /> 
                    <span class="textfieldMinCharsMsg">Minimum number of characters (3) not met.</span><span class="textfieldRequiredMsg">A name is required.</span></span></p>
                </blockquote></td>
                </tr><tr><td><blockquote>
                  <p><font color=red>*</font>Email<br/>
                    <span id="sprytextfield2">
                      <input type ="text" name="email" maxlength="30" value="<?php  echo $_POST['email'];?>" /> <br />
                      <span class="textfieldInvalidFormatMsg">A valid email is required.</span><span class="textfieldRequiredMsg">An email address is required.</span></span></p>
                  </blockquote></td>
                  </tr><tr><td><blockquote>
                    <p>Phone <font color=red>(not required)</font><br/>
                      <span id="sprytextfield3">
                        <input type="text" name="Phone" size="14" value="<?php  echo $_POST['Phone'];?>" />
                        <span class="textfieldMaxCharsMsg">Maximum 14 characters exceeded.</span></span></p>
                    </blockquote></td>
                    </tr><tr><td><blockquote>
                      <p><font color=red>*</font>Comments<br/>
                        <span id="sprytextarea1">
                          <textarea name="Comments" type ="text" cols="40" rows="5" size="500" value="<?php echo $_POST['Comments'];?>" /></textarea>
                          <span class="textareaMinCharsMsg"><br />
                          Minimum number of characters (10) not met.</span><br />
                        <span class="textareaRequiredMsg">A comment or question is required.</span></span></p>
                      </blockquote></td>
                      </tr><tr><td><blockquote>
    </form>

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Posts
    155
    Thanks
    34
    Thanked 1 Time in 1 Post
    Finally answered my own question and I had the php already in my thank you part.. textarea's do not have the value attribute so i used this and it works. (to safe face on sounding stupid.. i read that somewhere else :P ) so don't quote me..

    PHP Code:
     <textarea name="Comments" type ="text" cols="40" rows="5" size="500"><?PHP echo stripslashes(htmlentities ($_POST['Comments'])); ?></textarea>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •