/    Sign up×
Community /Pin to ProfileBookmark

HEADER problem

[code=php]
<?PHP
if (!isset($_SERVER[‘PHP_AUTH_USER’]) || $_COOKIE[‘isin’] != “1”) {
header(‘WWW-Authenticate: Basic realm=”My Realm”‘);
header(‘HTTP/1.0 401 Unauthorized’);
echo(“This is for authorized users only.”);
}else {
if($_SERVER[‘PHP_AUTH_USER’] == “1” && $_SERVER[‘PHP_AUTH_PW’]== “2”) {
echo “you got in”;
}else{
echo “wrong”;
}
}
?>
[/code]

what’s wrong with this sample?
after i type in user = 1 and password = 2, it cant echo “you got in” nor “wrong”;

and another question is the redirect problem:

[code=php]
$sec = 1;
// Redirects the browser after $sec seconds
header(“Refresh: $sec; http://www.php.net”);
echo “This content is displayed for $sec seconds, then the browser will redirect.”;
[/code]

it dont seems like direct to [url]www.php.net[/url] after 1 second.
is it need some changes in my php.ini?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guySep 21.2005 — well is the cookie set with value 1? if not this returns true and therefore the first if is done $_COOKIE['isin'] != "1"
×

Success!

Help @beginnerz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...