Forum Moderators: coopster

Message Too Old, No Replies

Basic PHP question (stripos)

PHP stripos question

         

frogz

8:38 am on Jan 18, 2009 (gmt 0)

10+ Year Member



Hello everyone!

Have a question regarding stripos..

heres the prob:


<?php
$idz = $owner->getVar('name');
$ident = $owner->getVar('uname');
$ownerid = $owner->getVar('uid');

if (stripos ($_SERVER['REQUEST_URI'], $idz) !== FALSE) {
header ("location:prod-".$owner."-".$ident.".htm");
}

?>

ok this works well actually, for when the owners "name" appears instead of the owners "uname", It works accordingly...

THE PROBLEM:

the $idz is the users "real name".
the $ident is the users "site username".

now, *some* people use their username AS their realname (they are both the same)
which poses a problem because php stripos is looking for their "realname"(in case) to complete the argument to direct it to their "username". When their username AND realname are the SAME ($idz=$ident) this creates an endless loop because it is actually changing it to their site uname but its the same! so it goes round n round! then poof! white page!

hope this makes sense to someone.
I need an argument where it can identify the $idz & the $ident as the same(when applicable), then skip over the stripos argument!

thanks!
regards, frogz

leadegroot

8:51 am on Jan 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try:

if (stripos ($_SERVER['REQUEST_URI'], $idz) !== FALSE
&& trim($idz) != trim($ident) ) {
header ("location:prod-".$owner."-".$ident.".htm");
}

?
(the trim is just paranoia)

frogz

9:01 am on Jan 18, 2009 (gmt 0)

10+ Year Member



blank page again, I'm afraid since the $idz (in this case) matches $ident, when it directs to $ident.htm, the stripos sees this still as $idz.htm (because theyre the same in this case) and still loops.. then white page.

thanks for the reply!

regards, frogz

frogz

9:04 am on Jan 18, 2009 (gmt 0)

10+ Year Member



not always does the $idz match the $ident, this depends if the user uses their username AS their realname as well.

frogz

9:06 am on Jan 18, 2009 (gmt 0)

10+ Year Member



maybe:
if $idz == $ident
ignore stripos;

I know thats laughable but is what im trying to do!

frogz

10:50 am on Jan 18, 2009 (gmt 0)

10+ Year Member



since the ones that are unfortunate enough to use their Username as their Real name all get white pages, I guess I will take out the "Enter your Real Name" field in the registration, so I dont have this problem in the future, for the new registrars. Although it will still leave the ones who have already done it (matched their uname and real name), with white pages. Im sure there's an easy solution. using the if & else arguments.

no more "Real Name" for them until I get this sorted!

Thanks for all your help, I will check back here to see if anyone has any more recommendations.

thanks for your time!

regards, frogz

rob7591

6:36 pm on Jan 18, 2009 (gmt 0)

10+ Year Member



if $idz == $ident
ignore stripos;

Instead of that why don't you do:

if ($idz != $ident) {
stripos...;
}

g1smd

10:12 pm on Jan 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That, or something very similar, should do it.