Page 1 of 1

echo back the value, so user does not have to re-enter

Posted: Tue Mar 21, 2006 7:51 am
by seaten
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi guys,

I have a form which a user has to fill in, but if certain fiels are incomplete or incorrect, I dont want the user to have to enter in all the details again. I am having problems with fiels of type file and textarea.

For example this works fine:

Code: Select all

<p<?php if (!empty($arrErrors['sel_product_weight'])) echo ' class="formerror"'; ?>>
    <label for="sel_product_weight">Product Weight:</label>
    <input name="sel_product_weight" type="Text" id="sel_product_weight" value="<?php echo $_POST['sel_product_weight'] ?>">    <?php if (!empty($arrErrors['sel_product_weight'])) echo '<img src="red triangle600.jpg" width="16" height="16" hspace="5" alt=""><br />'; ?>
</p>
________________________________________________
This doesnt remember the value of what the user entered, fiels of type "file" and type "textarea"

Code: Select all

<p<?php if (!empty($arrErrors['sel_product_description'])) echo ' class="formerror"'; ?>>
    <label for="sel_product_description">Product Description:</label>
  <TEXTAREA name="sel_product_description" wrap="physical" ROWS=6 COLS=40 id="sel_product_description" value="<?php echo $_POST['sel_product_description'] ?>"> </TEXTAREA>
    <?php if (!empty($arrErrors['sel_product_description'])) echo '<img src="red triangle600.jpg" width="16" height="16" hspace="5" alt=""><br />'; ?>
</p>


  
 <input type="hidden" name="MAX_FILE_SIZE" value="2000000">

 <p<?php if (!empty($arrErrors['sel_product_image'])) echo ' class="formerror"'; ?>>
    <label for="sel_product_image">Product Image:</label>
    <input name="userfile" type="file"  id="userfile" value="<?php echo $_POST['sel_product_image] ?>"> 
    <?php if (!empty($arrErrors['sel_product_image'])) echo '<img src="red triangle600.jpg" width="16" height="16" hspace="5" alt=""><br />'; ?>
</p>

So how I can have it set so it does remember it next time around ?


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Mar 21, 2006 10:04 am
by feyd
file fields cannot be written to.

As for textarea's

Code: Select all

<textarea><?php echo $foo; ?></textarea>

Posted: Tue Mar 21, 2006 10:23 am
by seaten
thanks feyd, that worked , Shame about it not working for fields of type "file"

Posted: Tue Mar 21, 2006 10:26 am
by feyd
It's a security issue. If writable, someone could create a hidden form that could automatically submit any file on your hard drive. Not a good idea.