IE7 PHP form $_POST variables headache

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oldsportbiker
Forum Newbie
Posts: 7
Joined: Wed Feb 24, 2010 10:21 pm

IE7 PHP form $_POST variables headache

Post by oldsportbiker »

I'm including just the basic snippets of code from "View Source" that is generated by 2 PHP form pages. The calling PHP page requests that a user click on someones last name and that button click is a submit to the calling form. The value passed in the value= "107" is the customer ID # as a string. The value that comes out of the called form is the selected name, (Diana Walker), rather than the button value, that appears as you can see below. The code works fine with FF and IE8. The onmouseover and onmouseout classes are included in the stylesheet linked in the head section.

Calling PHP form HTML source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="staff_search_one_employee.php" method="post" >
<button name="passed_employee_id" type="submit" value="107" class= "emp_button_reg" onmouseover="this.className='emp_button_over'" onmouseout="this.className='emp_button_reg'">Diana Walker</button>
</form>
</body>
</html>

Called PHP form HTML source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

passed Employee ID =Diana Walker

( the PHP code that produced this is the following :
$passed_employee_id=$_POST['passed_employee_id'];

echo "passed Employee ID =".$passed_employee_id;)

</body>
</html>
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: IE7 PHP form $_POST variables headache

Post by cpetercarter »

A quick Google search suggests that this is a known bug/feature in IE7 (it submits the button content instead of the button value). Could you use a normal input type=submit button instead? Or, you could include in the receiving page some code which would search for the empoyee id if the relevant $_POST variable is not a numerical value.
oldsportbiker
Forum Newbie
Posts: 7
Joined: Wed Feb 24, 2010 10:21 pm

Re: IE7 PHP form $_POST variables headache

Post by oldsportbiker »

Thanks, your Google skills certainly exceed mine, as I've been searching for the past 2 hours and went down many other paths. Again thanks
oldsportbiker
Forum Newbie
Posts: 7
Joined: Wed Feb 24, 2010 10:21 pm

Re: IE7 PHP form $_POST variables headache

Post by oldsportbiker »

In going back to replace button tag with input tag I remembered why I didn't do it in the first place. The application is an employee search page and lists many employees . While the user clicks on the name, it's the employee # that is unique and is used for a database query. I need to somehow pass the employee id to the called form without displaying it. With the button approach, the button value was the ID and the displayed text was the Name. If it was a form with only 1 set of vales, I could use a hidden input, but I don't think a hidden input will work from a list search page like this.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: IE7 PHP form $_POST variables headache

Post by cpetercarter »

You can make each line a separate form, and then you can submit a hidden input. If you are outputting the lines using a foreach loop, the coding shouldn't be too complex.
Post Reply