0

I am using PHP with a Microsoft SQL server and my users are all on IE9. I have a form that puts a variable into the value of a submit button to be posted to another page. I would like the face of the button to be different from the value so I was using this code:

echo "<button type='submit' value='".$userid."' name='userid'>Edit</button>";

The problem is that IE9 is passing 'Edit' to the next page instead of the variable in value.

Can this be fixed to work is there is another way to change the label on the face of the button besides the value?

Arphaxad
  • 3
  • 1
  • You sure? It should work in IE9. Are you in IE8 compatibility mode? See also: http://stackoverflow.com/questions/4171664/html-submit-button-different-value-button-text – GolezTrol Jul 22 '13 at 19:51

2 Answers2

1

It depends on your browser which value of a button is sent. (source)

Use input instead of button when you work with HTML forms and add a hidden input to send the user ID.

Pieter
  • 1,823
  • 1
  • 12
  • 16
0

Could you not add another input in to hold the user id like:

<input type="hidden" name="userid" value="'.$userid.'">

Then have your submit button separate:

<input type="submit" value="Edit" name="submit">
JohnnyFaldo
  • 4,121
  • 4
  • 19
  • 29
  • I tried this and it passes the last userid in the while loop. Here is the while statement that I am using: `while( $row = sqlsrv_fetch_array($stmt) ) { $userid = $row[2]; //+++START GET USER NAME+++ $ursql = "SELECT firstname, lastname FROM user WHERE id = '$row[2]'"; $urstmt = sqlsrv_query($link, $ursql); $urnm = sqlsrv_fetch_array($urstmt); $username = $urnm[0]." ".$urnm[1]; //+++END GET USER NAME+++ echo ""; }` – Arphaxad Jul 23 '13 at 12:50
  • ok, I used the hidden input type. I had to make each instance in the while loop it's own form. My code looks like this: `echo "
    ";`
    – Arphaxad Jul 23 '13 at 16:40