-
HTTP_POST_VARS question
I have a form that I dynamically create text boxes and the names respectively are text1, text2, text3, etc...... to text14.
When I click the submit button I am having issues with the $HTTP_POST_VARS code.
I just would like to know if I can do something like the following:
PHP Code:
for ($iArCnt=1; $iArCnt<15;$iArCnt++){
$sTmp = "text" . $iArCnt;
if (strlen($HTTP_POST_VARS($sTmp)) > 0){
$arFeature($iArCnt) = $HTTP_POST_VARS($sTmp);
} else {
$arFeature($iArCnt) = "";
}
}
Basically I would like to know how I can dynamically call each text.
Thanks in advance.
-
Yes, that should be able to work, however $HTTP_POST_VARS[] is deprecated. You should use $_POST[] instead (php 4.2+).
Try switching to $_POST[], and if it still doesn't work, get back to us and someone or I will help you figure it out.
-
Yeah, I got it working but had some minor issues to change. Here is what I ended up with:
PHP Code:
for ($iArCnt=1; $iArCnt<15;$iArCnt++){
$sTmp = "text" . $iArCnt;
if (strlen($HTTP_POST_VARS[$sTmp]) > 0){
$arFeature[$iArCnt] = $HTTP_POST_VARS[$sTmp];
} else {
$arFeature[$iArCnt] = "";
}
}
My big mistake was using () instead of []
-
Quote:
Originally posted by lleemon
Yeah, I got it working but had some minor issues to change. Here is what I ended up with:
PHP Code:
for ($iArCnt=1; $iArCnt<15;$iArCnt++){
$sTmp = "text" . $iArCnt;
if (strlen($HTTP_POST_VARS[$sTmp]) > 0){
$arFeature[$iArCnt] = $HTTP_POST_VARS[$sTmp];
} else {
$arFeature[$iArCnt] = "";
}
}
My big mistake was using () instead of []
Ah, I didn't catch that :)
However, as I have previously stated, $HTTP_POST_VARS[] is deprecated and should not be used. Use $_POST[] instead.