You should shorten this: if ($isid) { if ($1-) { to if ($isid) && ($1-) {
Also using the = in the var command I beleive allows you to add more length to variable (I heard this somewhere on here a while back)