473,325 Members | 2,816 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,325 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 2357
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.