Jump to content

How can I repopulate a dynamic text field?


phpretard

Recommended Posts

I have a form that you can add email boxes and recipients to.  when you add the boxes it actually submits.  I did it this way to change the session that determines how many boxes you get. 

 

The problem is if I (as a web user) have entered X number of emails and recipients then submit to add another  set of text fields then how can I keep the 3 already entered populated?

 

<?php
$start = $_SESSION['NOCStart'];
$stop = $_SESSION['NOCStop'];
for($m = $start; $m < $stop; $m++){
echo "
  <tr> 
	<td>$m: <input id='text' type='text' name='invEmail[]' value='WHATS GOES HERE??' /></td>
	<td><input id='text' type='text' name='invName[]' value='WHATS GOES HERE??' /></td>
  </tr>	
";
}
?>

 

The submitted info is captured with the following code:

For testing it simply outputs the info...

 

if (isset($_SESSION['NOC']) && $current_page == "invitations.php"){

if(isset($_POST['addemail'])){

$impEmail = implode(",", $_POST['invEmail']);
$expEmail = explode(",", $impEmail);
$impName = implode(",", $_POST['invName']);
$expName = explode(",", $impName);

$sendit = array_combine($expEmail, $expName);

foreach ($sendit as $key => $value) {
    	echo "$key belongs to $value<br />\n";
}

	if ($_SESSION['NOCStop'] == $_SESSION['NOC'] + 1){
		$message = "<script>alert('Max Emails Reached')</script>";

	}else{
		$_SESSION['NOCStart'] = 1;
		$_SESSION['NOCStop'] = $_SESSION['NOCStop'] + 1;
	}

}else{
	$stopper = $_SESSION['NOC'] * .5;	
	$rounder = round($stopper) + 1;
	$_SESSION['NOCStart'] = 1;
	$_SESSION['NOCStop'] = $rounder;

}

}

 

Thank you for your help!

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.