Just curious as sometimes contacting server admin can take forever. Is there something I can use to test if PHP_Auth is supported and working on my server?
Just curious as sometimes contacting server admin can take forever. Is there something I can use to test if PHP_Auth is supported and working on my server?
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
I believe its native as of php4.x
Well, you could write a simple script to test it I suppose. That would tell you if it is in fact supported.
Hope this helps.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
okay... so I wrote this:
well..I didn't write it, just modified it...PHP Code:<?php
$myusername = "user";
$mypassword = "pass";
$areaname = "This shows on the pop up!";
if ($_SERVER["PHP_AUTH_USER"] == "" || $_SERVER["PHP_AUTH_PW"] == "" || $_SERVER["PHP_AUTH_USER"] != $myusername || $_SERVER["PHP_AUTH_PW"] != $mypassword) {
header("HTTP/1.0 401 Unauthorized");
header("WWW-Authenticate: Basic realm=\"$areaname\"");
echo "<h1>Authorization Required.</h1>";
die();
}
?>
I put it on the very top (pre- opening html tag) and then browsed to that page. a passbox poped up. when I entered the correct username and password it didn't show the page, instead the passbox vanished, reappeared and both user and pass inputs were empty.
So... why won't it work? LOL Also.. if I do get it to work, and I wantto use it server wide do I need to make the variable global, or in their own script or do I need to put the whole thing on every page?
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
watch out for globals, they can get you in trouble,
save it to a session variable
okay.. err.. how? I have about reached the end of my php knowledge and I can't find anything that seems to help through google.
Can you help me write out something?
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
There ARE no globals. You don't need to save it as a $_SESSION variable, because the HTTP authentication saves itself on the browser. Meaning, it won't let you logout until you close the browser.
Blizzard, try this script:
PHP Code:<?php
$user='hi';
$pass='hi';
if (!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $pass)) {
header('WWW-Authenticate: Basic realm="Secured Area!!!!"');
header('Status: 401 Unauthorized');
die('<h1>Unauthorized Access</h1>');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Super Secret Stuff!!!</title>
</head>
<body>
<h1>hi.</h1>
</body>
</html>
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Thanks for that, I actually wrote a better working one than I needed. Of course I need to clean it up because I know I have more in there than I need.
But I will keep this one too, I am sure I can use it somewhere!
Thanks!
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
Bookmarks