.htaccess question
Moderator: General Moderators
.htaccess question
Hello, i'am making a prog (an elecronik atzenta tha people sign up and the can post or view records. In order for a user to post something when he hist the post button i want a .htaccess window to pop-up and ask him for user and pass! When he gives the correct user and pass then he is ok to post....but the problem is that .htaccess checks the .htpasswd file for username and password and not my mysql table members that has two filelds user and pass. How must i do to point .htaccess to compare the PHP_AUTH_USER and PHP_AUTH_PW to compare its values with my mebers records??
Send a 401 header from within your script, the browser will pop up the dialoag and resend the request with the given credentials. .htaccess or not the $_SERVER-elements are set and your script can decide wether to accept them or send a new 401.
see also, e.g. viewtopic.php?t=5937
see also, e.g. viewtopic.php?t=5937
Thanks volka i also wantes to ask about this:
<?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?
<?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?