Forum Moderators: coopster

Message Too Old, No Replies

Using [ in a form field and posting it

         

Drakash

1:16 pm on Nov 19, 2004 (gmt 0)



Hi folks,
First let me say a a long time lurker and first time poster tht this is an amazing resource.

Any way...onto my problem..

I have just been contracted to finish a project someone else wrote, its a shoping cart and catalogue system with loads of extra bits.

Now this system is written in PHP and mySQL and uses a standard web browser to display its content UNTIL the confirm order button is pressed, when it then POSTS the order form data into my clients SAP system.

This SAP system wants the names of the form fields it is recieving to be very specific and they must contain the [ character.

i.e. FORM_FIELD_NAME[1]

So I need to be able to make my form field names contain the [ symbol but NOT indicate the start of an array (the SAP system will do all the interpreting an d array handling). I just have to pass the form data with the right names.

Here's what I have right now..

...

$INDEX = array();
for($i = 0; $i < $LINES; $i++) {

$INDEX[] = $i;
}
$EMAIL = $_SESSION['EMAIL'];
$PASSWORD=$_SESSION['PASSWORD'];
$VENDOR=$_SESSION['VENDOR'];
$CONTRACT_NO=$_SESSION['CONTRACT_NO'];
$CARTTOTAL=$_SESSION['CARTTOTAL'];
$HOOK_URL=$_SESSION['HOOK_URL'];
$OKCode=$_SESSION['OKCode'];
$TARGET=$_SESSION['TARGET'];
$CALLER=$_SESSION['CALLER'];

foreach($INDEX as $key => $value) {

PRINT "
<input type=\"hidden\" size=\"100\" name=\"LINES\" value=\"$LINES\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-VENDOR\" value=\"$VENDOR\"><br>
<input type=\"hidden\" size=\"100\" name=\"EMAIL\" value=\"$EMAIL\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-MATGROUP[$key]\" value=\"$MATGROUP[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-DESCRIPTION[$key]\" value=\"$DESCRIPTION[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-QUANTITY[$key]\" value=\"$QUANTITY[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-PRICE[$key]\" value=\"$PRICE[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-UNIT[$key]\" value=\"$UNIT[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"NEW_ITEM-CURRENCY[$key]\" value=\"$CURRENCY[$key]\"><br>
<input type=\"hidden\" size=\"100\" name=\"CARTTOTAL\" value=\"$CARTTOTAL\"><br>
<input type=\"hidden\" size=\"100\" name=\"OKCode\" value=\"$OKCode\"><br>
<input type=\"hidden\" size=\"100\" name=\"TARGET\" value=\"$TARGET\"><br>
<input type=\"hidden\" size=\"100\" name=\"HOOK_URL\" value=\"$HOOK_URL\"><br>
<input type=\"hidden\" size=\"100\" name=\"CALLER\" value=\"$CALLER\"><br>";
}
......

But they are only ever recieving the data for the last item in the order.

How do I keep the naming convention they require (XXXX_XXXX_XXXX[x]). I wondered if it was possible to concat it together i.e.

.....name=\"NEW_MATRGROUP[".$key."]\">

So has anyone got any ideas?

all help most gratefully recieved

Drakash

jatar_k

5:00 pm on Nov 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Drakash,

hmm, that's a bit of a weird one. Have you looked at the source of the html page to see what that looks like? Do you get the proper output there and then only lose it on submit?

Trouble is that is an array character in pretty much any language, when you put a bunch of them on the same page they will end up in an array when posted.

Have you taken a look at the posted information to see what is falling apart?

IanKelley

10:54 pm on Nov 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The most straight-forward solution would be to post to a PHP script instead of the SAP system and then have the PHP script send the data in whatever format is needed.