.htaccess variables
Moderator: General Moderators
.htaccess variables
Hello how can i use the user name an d tha password varibales from a .htaccess request?
http://www.php.net/manual/en/reserved.variables.php
Server variables: $_SERVER
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_SERVER_VARS.
[...]
'PHP_AUTH_USER'
When running under Apache as module doing HTTP authentication this variable is set to the username provided by the user.
'PHP_AUTH_PW'
When running under Apache as module doing HTTP authentication this variable is set to the password provided by the user.
'PHP_AUTH_TYPE'
When running under Apache as module doing HTTP authenticated this variable is set to the authentication type.
<?php
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('db_nik');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=1;
if ($i==1)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Cyan> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
}
?>
How am i gonna be able to give the variables to the selected php scripts?
post the reposted variables i mean!
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('db_nik');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=1;
if ($i==1)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Cyan> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
}
?>
How am i gonna be able to give the variables to the selected php scripts?
post the reposted variables i mean!