Classic ASP.. what a headache

Friday, 5 December 2008

The company I'm working for currently is going through the process of transferring all their old classic asp sites over to php and adding new functionality at the same time.

In order to meet deadlines some of the new functionality is being added in classic asp and being converted over at a later date which is not the best way to do things but keeps things moving (please note: I wouldn't recommend this to anyone as an exercise).

One of the biggest troubles I've had is getting values out of arrays. With php if you have a variable and want to know what the hell is inside it you can just call var_dump or print_r and if it's an array it's quite easy to see that it's an array.

In classic asp it's not that easy.

One of the pages had a series of checkboxes as follows:

<input type="checkbox" value="1" name="selectioncriteria[]"/>
<input type="checkbox" value="2" name="selectioncriteria[]"/>
<input type="checkbox" value="3" name="selectioncriteria[]"/>
<input type="checkbox" value="4" name="selectioncriteria[]"/>

Which is a quite neat way to do things as you get all your selected values inside a single POST variable.

For php we can do the following: (Please remember to sanitise your data first folks)

foreach ($_POST['selectioncriteria'] as $criteria) {

For asp it's almost exactly the same: (It just takes half an hour of Googling to find out)

for each criteria in request("selectioncriteria[]")

Hope that helps someone from half an hour of frustration!
blog comments powered by Disqus