PDA

View Full Version : IMEI sum Check PHP



unlock432
30-07-2006, 12:06 PM
Yep, You probably guessed im big on the PHP, im also a rookie...a bad one at that.

I've work a PHP code that'll SUMCHECK the IMEI.

But, Being the incredible jackass that i Am, it doesn't work (apart from an IMEI that is all 0)

This is My Code:

<?
//Grabs the IMEI
$imei = $_REQUEST["imei"];

//Loops all the Odd IMEI numbers, then times it by 2
for( $i = 0 ; $i<14 ; $i++ ) {
$imei1 = $imei{$i}*2;
//THIS is where the main error is. It always shows up as Zero.
$imei1a = $imei1a + $imei1{0} + $imei1{1});
}
//Another Loop, For even numbers
for( $i = 1; $i<14; $i++) {
$imei2 = $imei{$i}*1;
$imei2a = $imei2 + $imei2a;
}

//Adds the Results together.
$imei3 = $imei2a + $imei1a;

//If the Remainder is 0 the sum check equals zero
if($imei3 % 10 == 0) {
$sum == 0;
}
//Otherwise:
else {
$sum == 10 - $imei3 % 10;
}
//Validation stage - Finds if valid or not
if($imei3 % 10 != $sum) {
echo 'Invalid';
} else {
echo 'Valid!';
}
//Code Made By UNLOCK432 =)
?>


Oh, if you have an example of a functioning PHP code, Please send it my way, I can gladly work off that :-D

THANKS IN ADVANCE!

ackxxx
16-12-2006, 11:33 PM
...
This is My Code:


...

//Loops all the Odd IMEI numbers, then times it by 2
for( $i = 0 ; $i<14 ; $i++ ) {
$imei1 = $imei{$i}*2;
//THIS is where the main error is. It always shows up as Zero.
$imei1a = $imei1a + $imei1{0} + $imei1{1});
}
...



look this one


for( $i = 0 ; $i<14 ; $i++ )
{ $imei1a[$i] = $imei[$i]*2; }

&& with only one var !:D :D