473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

User Authentication

5
Hi Gurus,
I have been working on my site pas few weeks almost 12 hrs a day. I came to a point and got stuck. I am hoping somebody can show me the way. What I want to do is: If a new user is visiting my page, I want to register his/her name,last name, userid and password. If already registered I would like to authenticate them so as soon as they type their userid and password, it will take them to their custome page. Well from tutorials and readings, I got to a point that. I can register them and it returns "registartion successful" page to them and it writes the info into my database. But when they login with a userid and password, it just returns "You are looged in" page. or "Passowrd/userid dont match" page. How can I make this authentication to direct them to the pages I want? I am using php,mysql and FrontPage to do all these. Please somebody help me. I am so frustrated. Thank you
Jan 20 '06 #1
5 2359
Hi, I am not sure if I understood you completely, but If I did, I think it is no difficult, I dont have frontpage experience, but since you are using php here is something that might help

This is the way you can do a redirection with php - I did not put all the code because you said you passed the point of authentication.

// Create Query to verify user and password
$Query = "select * from user where username=\"$Username\" and password=password(\"$Password\")";

$DBConnect = create the database connection here.

//Get a result file
$Result = mysql_query($Query,$DBConnect) or die('MySQL Query failed: ' . mysql_error());

// If we have a record means we found a user/password match - I assume usernames are unique, so that is why I am using the == 1
if (mysql_num_rows($Result) == 1) {
$url="http://myserver.com/ExistingUserPage.php";
} else {
$url="http://myserver.com/NewUserPage.php";
}

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


Hope this help
Jan 20 '06 #2
taylan
5
I will try this. Thank you for your response.
Jan 20 '06 #3
taylan
5
Hi Jen,
Thank you again for your previous response, I tried to put it in the following script of mine but didnt work. As soon as it authenticates the user, it still stays at the authentication page instead of directing to a new page. Can you see whats wrong below?

$request = "SELECT * FROM users WHERE password='".$pass."' AND username='".$user."'";

//Pass the request to the mysql connection,
//and the data is returned in a blob and
//saved in $results
$results = mysql_query($request,$conn);


//if mysql returns any number of rows great than 0, we know we had a match,
//right?
if(mysql_num_rows($results))//function returns true if any matches are found
{
$_SESSION['user'] = $user;
$_SESSION['auth'] = true;
$url="http://myserver.com/redirected.php";

}
else
{
echo "User Name/Password Pair Not Found.";
$_SESSION['auth'] = false;
}


//End PHP file authenticate.php
?>
Jan 21 '06 #4
Hello if you dont want to redirect the user to an error page if is not a valid user then the only thing you are missing is the redirection after you defined $url

if(mysql_num_rows($results))//function returns true if any matches are found
{
$_SESSION['user'] = $user;
$_SESSION['auth'] = true;
$url="http://myserver.com/redirected.php";
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}

That should do it, now, about your if statment, usernames must be unique, so I will expect the result set to have only one record, if more than one records are found something might be wrong with the query, the database or the request, so I suggest you to do a explicit if statement in which you verify that your query returns only one record.
Jan 21 '06 #5
taylan
5
That worked perfectly. Thanks again. You are the man...
Jan 21 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
4
by: Dan Bart | last post by:
I am using an application which is a modification of IBuySpy Portal. It is using Forms authentication. Users login and their name is added to Context Then I use: ...
5
by: Matthew Louden | last post by:
I wrote ASP.NET application that access SQL Server database. When I run the application, it yields "Login failed for user '<COMPUTER_NAME>\ASPNET'" error message. I then did the following, but...
8
by: Joe | last post by:
I check for the NTLogin of a user by Page.User.Identity.Name, but when I put the app on the server the value for Page.User.Identity.Name is "" I had the <allow users="*/> attribute commented...
15
by: Tom Nowak | last post by:
I am writing a webapp in which a user is required to enter a login id and password on a login form. I have forms authenticaion coded in my web.config. Once the user is logged in, I want to use the...
1
by: noor | last post by:
hi, can any one tell me a javascript that can be called on mouseover event of a html link control . script can check from session either a user is login or not In the case of Login it will...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
3
by: mario.colorado | last post by:
Hi! Does anyone know why it is that when I use: Request.LogonUserIdentity.User.ToString() I get something like: S-1-5-21-2268419..........
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
6
by: MuZZy | last post by:
Hi, I am looking to find a way to get currently logged in user's object GUID without querying ActiveDirectory. For example, when i log in to my laptop from home, I'm not on the office network so...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.