|
-
May 12th, 2007, 04:51 AM
#1
Thread Starter
Fanatic Member
new to php
Hi,
im newbie to php just wanna to ask how to put TextBox and Submit Button
example: this my website: http://www.ejcss.info/index.php?imei=123456789012347
when you visit that you'll get 10 digit of number, now i want is make 2 textbox and 1 button first text box is the 123456789012347 and second is the 10 digit number and one is Calculate Button... how to make this?
regards,
-
May 12th, 2007, 05:58 AM
#2
Addicted Member
Re: new to php
Code:
<form action="calculate.php" method="post">
<input type="text" size ="50" name="longnumber" value="123456789012347"><br>
<input type="text" size ="50" name="tendigit" value="<? echo $tendigitnumber; ?>">
<input type="submit" value="Go" />
Then in calculate.php grab the form values by using the following:
Code:
$longnumb = $_POST['longnumber'];
$10digit= $_POST['tendigit'];
F
-
May 12th, 2007, 06:04 AM
#3
Thread Starter
Fanatic Member
Re: new to php
Hi Ferris, dont understand.. can you make in php file?
-
May 12th, 2007, 06:07 AM
#4
Addicted Member
Re: new to php
can you post what you already have?
-
May 12th, 2007, 06:15 AM
#5
Thread Starter
Fanatic Member
-
May 12th, 2007, 06:22 AM
#6
Addicted Member
Re: new to php
I have only altered one line (almost the last line):
Code:
<?php
$tabla1 = array(0xB1,0xB1,0x73,0x73,0xE6,0xE6,0x5A,0x5A,0xAB,0xAB,0x47,0x47,0x8E,0x8E,0x0D,0x0D,0x1A,0x1A,0x34,0x34,0x68,0x68,0x0B,0x0B);
$tabla2 = array(0x34,0x62,0x58,0x92,0x76,0x13,0x25,0x97,0x56,0x28,0x68,0x13);
$unk = 0;
// *********************************
function string_to_array($cadena)
{
for ($i = 0; $i < strlen($cadena); $i++)
$nueva[$i] = ord(substr($cadena, $i, 1));
return $nueva;
}
function array_to_string($cadena)
{
$nueva = "";
foreach ($cadena as $valor)
{
$nueva .= chr($valor);
}
return $nueva;
}
//**********************************
function gethalf($donde, $off)
{
$valor = ($donde[$off+1] & 0xFF) << 8;
$valor |= $donde[$off+0] & 0xFF;
return $valor;
}
function sethalf($donde, $que, $off)
{
$donde[$off+0] = ($que & 0xFF);
$donde[$off+1] = (($que>>8) & 0xFF);
return $donde;
}
function inv($cadena)
{
for($i=0; $i<=10; $i+=2)
{
$temp = $cadena[$i];
$cadena[$i] = $cadena[$i+1];
$cadena[$i+1] = $temp;
}
return $cadena;
}
function calculo4a($param0)
{
global $unk;
$r1 = $unk;
$r0 = $param0 << 0x10;
$r2 = $r0 >> 0x10;
for($i=0; $i<=0xf; $i++)
{
$r1 = $r1 << 1;
$r0 = $r2;
$r0 &= 1;
$r1 |= $r0;
$r2 = $r2 >> 1;
}
$r0 = $r1;
return $r0;
}
function calculo4($param0)
{
$r0 = gethalf($param0,8);
$r0 = calculo4a($r0);
$r6 = $r0;
$r6 = $r6 << 0x10;
$r6 = $r6 >> 0x10;
$r0 = gethalf($param0,0xa);
$r0 = calculo4a($r0);
$r4 = $r0;
$r4 = $r4 << 0x10;
$r4 = $r4 >> 0x10;
$r0 = gethalf($param0,2);
$r0 = calculo4a($r0);
$param0 = sethalf($param0, $r0, 8);
$r0 = gethalf($param0, 0);
$param0 = sethalf($param0, $r0, 0xa);
$param0 = sethalf($param0, $r4, 0);
$param0 = sethalf($param0, $r6, 2);
$r0 = gethalf($param0, 4);
$r0 = calculo4a($r0);
$r4 = $r0;
$r4 = $r4 << 0x10;
$r4 = $r4 >> 0x10;
$r0 = gethalf($param0, 6);
$r0 = calculo4a($r0);
$param0 = sethalf($param0, $r0, 4);
$param0 = sethalf($param0, $r4, 6);
return $param0;
}
function calculo3($param0)
{
$temp = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
for($i=0; $i<=5; $i++)
{
$r0 = $i << 1;
$r2 = gethalf($param0, $r0);
$temp = sethalf($temp, $r2, $r0);
$r0 = $i + 6;
$r0 = $r0 << 1;
$temp = sethalf($temp, $r2, $r0);
}
for($i=5; $i>=0; $i--)
{
$r1 = $i << 1;
$r0 = $i + 4;
$r0 = $r0 << 1;
$r0 = gethalf($temp, $r0);
$r2 = ~$r0;
$r0 = $i + 2;
$r0 = $r0 << 1;
$r0 = gethalf($temp, $r0);
$r0 |= $r2;
$r4 = gethalf($param0, $r1);
$r0 ^= $r4;
$param0 = sethalf($param0, $r0, $r1);
}
return $param0;
}
function calculo2($param0, $off0, $off1)
{
$r5 = gethalf($param0, $off0);
$r3 = gethalf($param0, $off0+2);
$r2 = $r3 << 0x10;
$r5 |= $r2;
$r4 = gethalf($param0, $off0);
$r6 = $r4 << 0x10;
$r6 |= $r3;
$r2 = $r5 >> 0xa;
$param0 = sethalf($param0, $r2, $off0);
$r2 = $r6 >> 0xa;
$param0 = sethalf($param0, $r2, $off0+2);
$r5 = gethalf($param0, $off1);
$r2 = gethalf($param0, $off1+2);
$r0 = $r2 << 0x10;
$r5 |= $r0;
$r4 = gethalf($param0, $off1);
$r6 = $r4 << 0x10;
$r6 |= $r2;
$r0 = $r5 >> 0xF;
$param0 = sethalf($param0, $r0, $off1+2);
$r0 = $r6 >> 0xF;
$param0 = sethalf($param0, $r0, $off1);
return $param0;
}
function calculo1b($param0, $param1, $param2, $param3, $off0, $off1, $off2, $off3)
{
global $unk;
$r6 = gethalf($param0, $off0);
$r4 = $r6 << 8;
$r9 = $r4;
$r4 ^= $r6;
$r5 = gethalf($param0, $off0+2);
$r4 ^= $r5;
$r8 = $r4;
$r4 = $r5 << 8;
$r5 ^= $r4;
$r5 ^= $r6;
$r4 = $r9;
$r5 ^= $r4;
$r0 = $param0[$off0+1] & 0xFF;
$r5 ^= $r0;
$r0 = $param1[$off1+3] & 0xFF;
$r4 = gethalf($param1, $off1+2);
$r0 ^= $r4;
$r4 = $r8;
$r0 ^= $r4;
$r0 = $r0 << 0x10;
$r0 = $r0 >> 0x10;
$r1 = gethalf($param1, $off1);
$r1 ^= $r5;
$temp1 = $r1;
$r4 = $r1 << 0x10;
$r4 = $r4 >> 0x10;
$temp1 = $r4;
$r4 = gethalf($param2, $off2+2);
$r0 ^= $r4;
$r4 = gethalf($param2, $off2);
$r1 = $r4 << 8;
$r0 ^= $r1;
$r1 = $param2[$off2+1] & 0xFF;
$r0 ^= $r1;
$r4 = gethalf($param2, $off2+2);
$r4 = $r4 << 8;
$temp2 = $r4;
$r0 ^= $r4;
$r1 = $param2[$off2+3] & 0xFF;
$r0 ^= $r1;
$param3 = sethalf($param3, $r0, $off3);
$r0 = gethalf($param2, $off2);
$r4 = $temp1;
$r0 ^= $r4;
$r1 = $param2[$off2+1] & 0xFF;
$r0 ^= $r1;
$r4 = gethalf($param2, $off2+2);
$r1 = $r4 << 8;
$r0 ^= $r1;
$r1 = $param2[$off2+3] & 0xFF;
$unk = $r1;
$r0 ^= $r1;
$param3 = sethalf($param3, $r0, $off3+2);
return $param3;
}
function calculo1a($param0)
{
//for(i=0; i<12; i++)
//{
// temp[i] = param0[i];
// }
$temp = $param0;
$param0 = calculo1b($temp, $temp, $temp, $param0, 0, 4, 8, 0);
$param0 = calculo1b($temp, $temp, $temp, $param0, 4, 8, 0, 4);
$param0 = calculo1b($temp, $temp, $temp, $param0, 8, 0, 4, 8);
return $param0;
}
function calculo1($param0, $param1, $param2, $off2)
{
$r3 = gethalf($param1, 0);
$r4 = gethalf($param0, 0);
$r3 ^= $r4;
$param1 = sethalf($param1, $r3, 0);
$r3 = gethalf($param0, 2);
$r4 = gethalf($param2, $off2);
$r3 ^= $r4;
$r4 = gethalf($param1, 2);
$r3 ^= $r4;
$param1 = sethalf($param1, $r3, 2);
$r3 = gethalf($param1, 4);
$r4 = gethalf($param0, 4);
$r3 ^= $r4;
$param1 = sethalf($param1, $r3, 4);
$r3 = gethalf($param1, 6);
$r4 = gethalf($param0, 6);
$r3 ^= $r4;
$param1 = sethalf($param1, $r3, 6);
$r4 = gethalf($param0, 8);
$r2 = gethalf($param2, $off2);
$r4 ^= $r2;
$r2 = $r4;
$r4 = gethalf($param1, 8);
$r2 ^= $r4;
$param1 = sethalf($param1, $r2, 8);
$r4 = gethalf($param1, 0xa);
$r0 = gethalf($param0, 0xa);
$r4 ^= $r0;
$r0 = $r4;
$param1 = sethalf($param1, $r0, 0xa);
$param1 = calculo1a($param1);
return $param1;
}
function calc_code($param0, $param1, $param2)
{
for($i=0; $i<=10; $i++)
{
$r2 = $i << 1;
$param1 = calculo1($param0, $param1, $param2, $r2);
$param1 = calculo2($param1, 0, 8);
$param1 = calculo3($param1);
$param1 = calculo2($param1, 8, 0);
}
$param1 = calculo1($param0, $param1, $param2, 0x16);
$param1 = calculo4($param1);
return $param1;
}
function calc_mcode($imei_or)
{
global $tabla1;
global $tabla2;
$imei_hex = array(0,0,0,0,0,0,0,0,0,0,0,0);
$destino = array(0,0,0,0,0,0,0,0,0,0);
$imei = string_to_array($imei_or);
$imei_hex = sethalf($imei_hex, 0, 0);
$imei_hex = sethalf($imei_hex, 0, 8);
$imei_hex = sethalf($imei_hex, 0, 0xa);
for($i=0; $i<=6; $i++)
{
$r0 = $i << 1;
$r1 = $imei[$r0];
$r1 &= 0x0F;
$r1 = $r1 << 4;
$r0 = $imei[$r0+1];
$r0 &= 0x0F;
$r1 |= $r0;
$imei_hex[$i+2] = $r1;
}
$imei_hex = inv($imei_hex);
$imei_hex = calc_code($tabla2, $imei_hex, $tabla1);
$imei_hex = inv($imei_hex);
$r1 = 0;
for($i=0; $i<=4; $i++)
{
$r1 = $i << 1;
$r0 = $imei_hex[$i];
$r0 = $r0 >> 4;
$r0 &= 7;
$r0 += 0x30;
$destino[$r1] = $r0;
$r0 = $imei_hex[$i];
$r0 &= 7;
$r0 += 0x30;
$destino[$r1+1] = $r0;
}
return $destino;
}
if (isset($_GET['imei']))
{
$imei = $_GET['imei'];
$code = array_to_string(calc_mcode($imei));
$tendigitnumber= "".$code; //THIS LINE HAS BEEN CHANGED
}
?>
<html>
<body>
<form action="calculate.php" method="post">
<input type="text" size ="50" name="longnumber" value="123456789012347"><br>
<input type="text" size ="50" name="tendigit" value="<? echo $tendigitnumber; ?>">
<input type="submit" value="Go" />
</body>
</html>
Then in a new php file (calculate.php) you can access the text box values like so:
Code:
$longnumb = $_POST['longnumber'];
$10digit= $_POST['tendigit'];
F
-
May 12th, 2007, 06:32 AM
#7
Thread Starter
Fanatic Member
Re: new to php
ok.. but when i try errors give me: check http://www.ejcss.info/calc.php
-
May 12th, 2007, 10:34 AM
#8
Addicted Member
Re: new to php
What exactly is it that you are trying to achieve?
Do you want to to have the long number displayed in one text box and the 10 digit number displayed in another text box. Is that correct?
F
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|