Results 1 to 3 of 3
Thread: Apache+PHP HTML form problem
-
07-25-2005, 07:09 AM #1WHT Addict
- Join Date
- Feb 2005
- Posts
- 124
Apache+PHP HTML form problem
I am running Apache/2.0.54 (Win32) PHP/4.3.11
and having problem with form posting
on a form I check multiple checkboxes, browser submits all 3 'Save' values (see tcp dump)
but php sees only last one how come ?
is there setting in Apache or php I missed ?
<?php
echo "<form action='test.php' method='post'>
<input type='checkbox' name='Save' value='1'>
<input type='checkbox' name='Save' value='2'>
<input type='checkbox' name='Save' value='3'>
<input type='image' name='do' value='update' src='/img/1.gif'>
</form>";
foreach ($_POST as $varName => $varValue)
{
echo $varName."=".$varValue."<br>";
}
?>
===========================
Output
---------------------------
Save=3
do_x=15
do_y=10
do=update
===========================
TCP DUMP
---------------------------
Content-Type: application/x-www-form-urlencoded
Content-Length: 45
Save=1&Save=2&Save=3&do.x=11&do.y=9&do=update
===========================Last edited by AlphaOne; 07-25-2005 at 07:19 AM.
-
07-25-2005, 09:31 AM #2Newbie
- Join Date
- Jul 2005
- Posts
- 14
You are assigning the "name" variable 3 different values so php will go with the last one defined
-
07-25-2005, 02:54 PM #3WHT Addict
- Join Date
- Feb 2005
- Posts
- 124
lao_v, thanks for restating what i said.
In IIS & ASP simular function works propely, in Apache & PHP it only works if i use
<input type='checkbox' name='Save[]' value='1'>
<input type='checkbox' name='Save[]' value='2'>
Then PHP puts 1,2,... in array called Save, but isn't there a setting to make it work regularly ?
========================
<%@ LANGUAGE="VBSCRIPT"%>
<%
response.write "<form action='test2.asp' method='post'>" &_
"<input type='checkbox' name='Save' value='1'>" &_
"<input type='checkbox' name='Save' value='2'>" &_
"<input type='checkbox' name='Save' value='3'>" &_
"<input type='image' name='do' value='update' src='/img/1.gif'>" &_
"</form>"
For each objItem in Request.Form
Response.Write objItem &" = "& Request.Form(objItem) &"<br>"
Next
%>
=======================
Output
-----------------------------------------
Save = 1, 2, 3
do.x = 13
do.y = 20
do = update
=======================Last edited by AlphaOne; 07-25-2005 at 03:00 PM.