Hi,

I want to pass the parameter of employee_id to a page. My code is working fine and passing parameter to page but the problem is rather then the current parameter , It is passing the previous parameter which was selected in previous submit. Below is the code.

<form action='manager_employee_select.php?proc_employee_id=<?php echo $_POST['proc_employee_id']; ?>' method="POST">
<table>
<tr> My team members timesheet</tr>

<tr>Select a team member from the list to continue</tr>
<tr>
	
		<?php
   		$conn = pg_connect("host=localhost port=5432 dbname=aim user=postgres password=holiday");
 		$result = "select employee_id,first_name || '' || last_name as name from employee where reporting_manager_id = '1113'";
     		$result =  pg_query($conn, $result) or die(pg_last_error());
		
		?>

		<?php echo "<td name = \"employees\"  >
		<select name=\"proc_employee_id\" id=\"dropdown\" >"; ?>
		<option value=""></option>5
		<?php
  
	  	while($emps = pg_fetch_assoc($result))
		{
  		$val = $emps["employee_id"];
  		$caption = $emps["name"]; ?>
		<option value="<?php echo $val ?>"><?php echo $caption ?></option>
		<?php }  ?></select>
	    	</td>
</tr>
</table>
<input name="submit" value="Continue" type="submit">
</form>

Many Thanks In advance

Recommended Answers

All 5 Replies

Your problem will be this line:

<form action='manager_employee_select.php?proc_employee_id=<?php echo $_POST['proc_employee_id']; ?>' method="POST">

This will put the proc_employee_id from the previous form as in the URL for this forms action.

Is there any solution for it? BY which i can use the current value to be used as parameter

Since you want to pass the proc_employee_id, you are already passing it when you submit the form. All of the items in the form will be posted to the action page. Therefore you dont need

?proc_employee_id=<?php echo $_POST['proc_employee_id']; ?>

in the action.

Although I see some trouble with your select. It should more resemble something like this:

<?echo "<td name = \"employees\"  >
		<select name=\"proc_employee_id\" id=\"proc_employee_id\" >"; ?>
		<option value="5">5</option>

You technically only need an id but the name is fine. The value will be what you get when you $_POST on the action page.

Thanks , I found a way out.jekl your answer did helped me thank you very much.

Hi,

I want to pass the parameter of employee_id to a page. My code is working fine and passing parameter to page but the problem is rather then the current parameter , It is passing the previous parameter which was selected in previous submit. Below is the code.

<form action='manager_employee_select.php?proc_employee_id=<?php echo $_POST['proc_employee_id']; ?>' method="POST">
<table>
<tr> My team members timesheet</tr>

<tr>Select a team member from the list to continue</tr>
<tr>
	
		<?php
   		$conn = pg_connect("host=localhost port=5432 dbname=aim user=postgres password=holiday");
 		$result = "select employee_id,first_name || '' || last_name as name from employee where reporting_manager_id = '1113'";
     		$result =  pg_query($conn, $result) or die(pg_last_error());
		
		?>

		<?php echo "<td name = \"employees\"  >
		<select name=\"proc_employee_id\" id=\"dropdown\" >"; ?>
		<option value=""></option>5
		<?php
  
	  	while($emps = pg_fetch_assoc($result))
		{
  		$val = $emps["employee_id"];
  		$caption = $emps["name"]; ?>
		<option value="<?php echo $val ?>"><?php echo $caption ?></option>
		<?php }  ?></select>
	    	</td>
</tr>
</table>
<input name="submit" value="Continue" type="submit">
</form>

Many Thanks In advance

Hi,

<form action='manager_employee_select.php?proc_employee_id=<?php echo $_POST['proc_employee_id']; ?>' method="POST">

Instaed of above code use below one: <form action='manager_employee_select.php' method="POST"> if u want previous submit value make this field hidden in this page only but with different name


This will solve your problem......sure....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.