How to fix Notice: Undefined variable: REFERER

Good Morning!

I’m getting tons of Notice: Undefined variable: REFERER on line 116 I messed with it for hours. How can I fix this?

<?php
if(isset($_SERVER['HTTP_REFERER'])) {
$REFERER = $_SERVER['HTTP_REFERER'];
//echo $_SERVER['HTTP_REFERER'];
}; ?>

<?php if (($REFERER !== 'https://'.$_SERVER['HTTP_HOST'].'/customer/account/create/') && ($REFERER !== 'https://'.$_SERVER['HTTP_HOST'].'/'. $storeLocaleCodeLowerCase.'/customer/account/create/')): ?>  <---this line
//stuff here

<?php endif; ?>

The second bit could maybe go into the isset clause, but that may not suit your needs.
Possibly an else after the isset to set it something like false or “No Referrer!”, just so it’s set to something in either case.

Thanks I think that fixed it. Here’s the new code:

[code]

<?php if(isset($_SERVER['HTTP_REFERER'])): ?> <?php $REFERER = $_SERVER['HTTP_REFERER']; ?> <?php else: ?> <?php $REFERER = 'https://'.$_SERVER['HTTP_HOST'].'/'; ?> <?php endif; ?> <?php if (($REFERER !== 'https://'.$_SERVER['HTTP_HOST'].'/customer/account/create/') && ($REFERER !== 'https://'.$_SERVER['HTTP_HOST'].'/'. $storeLocaleCodeLowerCase.'/customer/account/create/')): ?>

//stuff here

<?php endif; ?>[/code]

We’ll see : )

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.