Hi
need an advice, I'm beginner with PHP. I got little problem:
I use this solution as login to get administration of my pages:
<?php
// if authorization isn't done we request it
if (!IsSet($PHP_AU TH_USER))
{
Header("HTTP/1.0 401 Unauthorized");
Header("WWW-Authenticate: Basic realm=\"RS - Admin Center\"");
echo "Unauthoriz ed access (a)";
exit;
}
// if user filled up the form we continue with checking data in
database
else
{
// connect to database
include "../conn.php";
// looking for the login and password records that are set in
authorizing form
// we off-course looking for active users only
$sql = mysql_query("SE LECT * FROM autori
WHERE login LIKE '$PHP_AUTH_USER '
AND pass = '".md5($PHP_AUT H_PW)."'
AND stav = 'a'");
// if we won't find anyone with requested conditions we stop
if (mysql_num_rows ($sql) == 0)
{
Header("HTTP/1.0 401 Unauthorized");
Header("WWW-Authenticate: Basic realm=\"RS - Admin Center\"");
echo "Unauthoriz ed access (b)";
mysql_close($co nn);
exit;
}
// we don't need the connection with database so we end
mysql_close($co nn);
}
// continue with opening frames
?>
The problem is that I can not get success with login on my pages
though I use correct login and password. The dialog is opened three
times and then I get the message Unauthorized access (a). It seems
that the part after else command is never done. Why is it?
Thank you very much for your hints!
Have a nice day! 3 1496
On Apr 26, 10:07 pm, MIUSS <m...@seznam.cz wrote:
Hi
need an advice, I'm beginner with PHP. I got little problem:
I use this solution as login to get administration of my pages:
<?php
// if authorization isn't done we request it
if (!IsSet($PHP_AU TH_USER))
{
Header("HTTP/1.0 401 Unauthorized");
Header("WWW-Authenticate: Basic realm=\"RS - Admin Center\"");
echo "Unauthoriz ed access (a)";
exit;}
// if user filled up the form we continue with checking data in
database
else
{
// connect to database
include "../conn.php";
// looking for the login and password records that are set in
authorizing form
// we off-course looking for active users only
$sql = mysql_query("SE LECT * FROM autori
WHERE login LIKE '$PHP_AUTH_USER '
AND pass = '".md5($PHP_AUT H_PW)."'
AND stav = 'a'");
// if we won't find anyone with requested conditions we stop
if (mysql_num_rows ($sql) == 0)
{
Header("HTTP/1.0 401 Unauthorized");
Header("WWW-Authenticate: Basic realm=\"RS - Admin Center\"");
echo "Unauthoriz ed access (b)";
mysql_close($co nn);
exit;
}
// we don't need the connection with database so we end
mysql_close($co nn);}
// continue with opening frames
?>
The problem is that I can not get success with login on my pages
though I use correct login and password. The dialog is opened three
times and then I get the message Unauthorized access (a). It seems
that the part after else command is never done. Why is it?
Thank you very much for your hints!
Have a nice day!
you are using an old script, use
$_SERVER['PHP_AUTH_PW']
$_SERVER['PHP_AUTH_USER']
and adjust your query to
....
WHERE login LIKE '".$_SERVER['PHP_AUTH_USER']."'
...
to avoid issue with quotes now, and it should be fine.
Hi!
I'm little confused, I tried more things but I still didn't get
success.
I think this should be corect:
$sql = mysql_query("SE LECT * FROM autori
WHERE login LIKE \"".
$_SERVER['PHP_AUTH_USER']."\"
AND pass LIKE
\"".md5($_SERVE R['PHP_AUTH_PW'])."\"
AND stav LIKE a\";");
But it isn't and it does not work:-(
On Apr 27, 7:13 pm, MIUSS <m...@seznam.cz wrote:
Hi!
I'm little confused, I tried more things but I still didn't get
success.
I think this should be corect:
$sql = mysql_query("SE LECT * FROM autori
WHERE login LIKE \"".
$_SERVER['PHP_AUTH_USER']."\"
AND pass LIKE
\"".md5($_SERVE R['PHP_AUTH_PW'])."\"
AND stav LIKE a\";");
But it isn't and it does not work:-(
dont use LIKE, instead use = and your query should be better formed,
go check out how to authenticate with mysql, and look for the query
used, and follow the example,
$query = sprintf( "SELECT.... .. WHERE `login` = '%s' ......",
$_SERVER['PHP_AUTH_USER'] [,......] );
etc.... google for this rather than just trying stuff, else you will
get it wrong. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bartosz Wegrzyn |
last post by:
I need help with sessions.
I createt set of web site for nav with authorization.
first I go into main.php which looks like this:
<?php
//common functions
include_once '../login/common.php';
global $LOGINDIR;
|
by: Keith Norris |
last post by:
I am having a problem connecting to my SQL Server with the following ASP
code:
set cn = server.createobject("adodb.connection")
cn.connectionstring = "Provider=sqloledb; data source=midatlanticus;
Integrated Security=SSPI"
cn.open
But, if I use the same connection string in a VB program, I connect
successfully. The VB code that works successfully is as follows:
|
by: Zlatko Matić |
last post by:
Hi!
In MS Access/PostgreSQL combination I have login form. After user writes all
neccessary inputs and push the button, a startup procedure creates DSN-less
connection string, receates all linked tables and change connection string
in all pass-through queries. It works nice...
But, how to achieve LOGOUT ? I would like to allow users to login/logout
consecutively from MS Access front-end without need to close front-end.
I tried to perform...
|
by: Brian Conway |
last post by:
I have no idea what is going on. I have a Login screen where someone types
in their login information and this populates a datagrid based off of the
login. Works great in debug and test through VS, however, when I change to
release and put it out on the web it fails giving me the following error
message
The underlying connection was closed. Could not establish a trust
relationship with the remote server.
|
by: rrober07 |
last post by:
Hello,
My Setup is I have a Web Server machine(Devweb01), Database SQL
Machine(Devsql01), a Client Machine(local machine) I have configured the
SQL machine as follows:
1) Added local Aspnet user account (with same password as aspnet user on IIS
(Devweb01))
2) edited local machine.config file <ProcessModel> Password attribute to
same password (both on IIS and SQL Machine)
3) SQL Server security is Sql Server and Windows
| |
by: peshekeedweller |
last post by:
Using asp.net 1.1. vb.net 2003.
I am trying to connect to a remote sql server 2000 on a virtual machine
running windows 2000 server. I can connect through the server explorer in
visual studio, but cannot connect through code. I have done it before and
can not do it now; I don't know what changed. (I also cannot connect to
local Access database through code though I can from server explorer.)
The code is:
conn = New SqlConnection("data...
|
by: Gordon |
last post by:
I want to add a feature to a project I'm working on where i have
multiple users set up on my Postgres database with varying levels of
access. At the bare minimum there will be a login user who only has
read access to the users table so that users can log in. Once a user
has been logged in successfully I want to escalate that user's access
level to one appropriate to their role, which will include switching
the postgres user they are...
|
by: Brett |
last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a
different box from the web server) and displays the result in a GridView.
The datasource for the GridView is a SQLDataSource. Just to get it to work,
I hard-coded the username and password of a SQL Server account in the
connectionstring in web.config. Once I confirmed that this worked on the
web server, I wanted to remove the hard-coded password from web.config, so I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |