0

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

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by poojamakhija
0

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.

0

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

0

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.

Edited by dr jekl: n/a

0

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

0

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....

Edited by peter_budo: Keep It organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.