PHP Array & strpos Question?

Chris Y

New member
Normally I'm quite good with PHP...However I'm stuck.....

All I'm trying to re-create is the HSBC Online Banking Login Form...

For those who don't know who this works.... It will ask you for a security number (In this case 123456) BUT it won't ask you for the exact string, it'll ask for a randomly generated value..

E.g one time it may ask for; First, Third and Last digit of the security number, another time it might ask for; Second, Fourth and Second to last digit of your security number. and so on.....

All i'm trying to do is re-create this for a uni project...

I have an array with 1,2,3,4,5,6 stored in it (For the randomly generated request)
I then randomly pick 3 numbers out of the array (E.g 1 =First, 2 = Second.....)

After that i pull in the security number stored in a database and store it to the session. (in this case i have hard coded it)

After so, i then create the number the user has to put in using strpos() which, using the randomly generated number, gets that reference from the security number,

For example; RANDOMLY GENERATED NUMBERS: 2,4,6 SO i get the script to take out the; Second, Fourth and Sixth number of the security number and store that to a variable and check it agasint what the user has inputted....Make sense?

However, the code doesn't want to work for some reason...Have a look:

<?php
$array = array(1,2,3,4,5,6);
$random1 = $array[rand(0,5)];
$random2 = $array[rand(0,5)];
$random3 = $array[rand(0,5)];

echo $random1. $random2. $random3."<br/>";

$_SESSION['securityNumber'] = 123456;

$secNumShort = strpos($_SESSION['securityNumber'],$random1). strpos($_SESSION['securityNumber'],$random2). strpos($_SESSION['securityNumber'],$random3);
echo $secNumShort;
?>
 
Back
Top