Forum Moderators: coopster

Message Too Old, No Replies

Undefined index: referral

         

Hitman3266

8:41 am on May 6, 2007 (gmt 0)

10+ Year Member



<input type="text" name="default_options[referral_name]" value="'.$_COOKIE["referral"].'" size="30" tabindex="', $context['tabindex']++, '" />

when the cookie exists its fine, but when the cookie doesnt exist it gives the error

henry0

11:46 am on May 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you check if the cookie exists before those lines
if not
do somehing else and exit();

Hitman3266

12:32 pm on May 6, 2007 (gmt 0)

10+ Year Member



i dont know how to check it, i made a function with isset and then put it in the value but its SMF and im getting a template error, maybe i did something wrong or missed some bracket or soemthing

henry0

12:45 pm on May 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please, post some pertaining code.

Hitman3266

9:41 pm on May 6, 2007 (gmt 0)

10+ Year Member



its just a cookie, it gets WRITTEN, now you try to READ the cookie

<input type="text" name="default_options[referral_name]" value="'.$_COOKIE["referral"].'" size="30" tabindex="', $context['tabindex']++, '" />

.$_COOKIE["referral"].
is where it gets read, now when the cookie doesnt exist it gets the undefined index (cause the cookie doesnt exist), but the cookie is only made when someone goes to ref=username, so people who go to register straight away dont get the cookie and thus on them when it tries to
.$_COOKIE["referral"].
it gives the undefined index, i need a way to put into the code above with value="' some type of isset command or something

henry0

11:26 am on May 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if (!isset($_COOKIE['referral']))
{
// if it does not exit
// I don't know what you want to do
// maybe go back somewhere and do something?
echo"You need to do this or that <br />
Please <a href='go_there.php'> Try Again!</a>";
}
else
{
// else we know that it is set therefore you could:
// offer your form with that cookie as you posted
}

whoisgregg

1:22 pm on May 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It can also be done inline using ternary operators [php.net]:

<input type="text" name="default_options[referral_name]" value="'.( (isset($_COOKIE["referral"]) )? $_COOKIE["referral"] : '' ).'" size="30" tabindex="', $context['tabindex']++, '" />