Jump to content

form fields not retaining data on post


fife

Recommended Posts

Ok from one brick wall to the next. After lots of help with my last query I moved onto the next task an I'm completely stuck again.

 

I have a form thats created with a loop.  Here is that form

 

<form action="" method="post" id="">
        <?php 
 for ($i = 1; $i <= $totalRows_rs_cacheNum; $i++) {
    echo "<label>Cache ".$i."</label>
       	  <span id='sprytextfield".$i."'>
        	<input name='cache[$i]' type='text' value='".$_POST['cache[$i]']."'/>
        	<span class='textfieldRequiredMsg'>Required!</span></span>
        	<div class='clear'></div>";
}
?>
<input name="nextbtn" type="submit" value="Next" />

 

When a user enters data in all the fields, If one piece of information is incorrect an error pops up saying one of the fields you entered does not match the fields in the database. At the same time however i wish to keep the data they have entered in each of the fields.

 

Normally you'd just write

 

value="<?php echo $_POST['fieldName'];?>"

 

but for some reason in this case it does not work. can someone point me in the right direction.  I've tried Google many different terms but I can not find the correct term to find my answer.  Hence me asking you guys again.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.