473,407 Members | 2,312 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,407 software developers and data experts.

Problem communication with database

i using ubuntu lamp server.
In my mysql database i have a table called users, which store the user and there password. i created a php page called login.php where you bacially have to log into.
when i am running the page and type in a user and there password and click submit button. All that happening is text fields become clear and that it.
how do i solve this problem?
Feb 14 '08 #1
9 1293
harshmaul
490 Expert 256MB
Hi,
just stick the user ID in to a session variable/cookie, and then us that to tell whether the user is logged in.

Secondly when the user submits the form and you have confirmed and logged the session.... use

Expand|Select|Wrap|Line Numbers
  1. header("location:nextpage.php");
to display the index of the next page after logging in.

http://www.codersadvocate.com/blogs/...dministration/

Heres an article i wrote a while back that might help you
Feb 14 '08 #2
nathj
938 Expert 512MB
i using ubuntu lamp server.
In my mysql database i have a table called users, which store the user and there password. i created a php page called login.php where you bacially have to log into.
when i am running the page and type in a user and there password and click submit button. All that happening is text fields become clear and that it.
how do i solve this problem?

Hi,
Let's see some code. I'd like to see the login.php and any code used to query the database that is not in this file. It would also be useful to know the data structure.

Post it all back here and I'll try to help out.

Cheers
nathj
Feb 14 '08 #3
ronverdonk
4,258 Expert 4TB
Welcome to TSDN pricelindie!

For the structure of such a login script, have a peek HERE and check if your application lacks something.

Ronald
Feb 14 '08 #4
Hi,
Let's see some code. I'd like to see the login.php and any code used to query the database that is not in this file. It would also be useful to know the data structure.

Post it all back here and I'll try to help out.

Cheers
nathj
[php]
[<?session_start()?>
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
<?php
$links = "<a href='main.php'> GO to main page</a><br><a href= 'logout.php'> Go to logout";


if ($user && $pass){
if ($logged_in_user ==$user){
echo $user.", You are already logged in.<br><br>";
echo $links;
exit;
}
$db =mysql_connect("localhost","whitney","password")or die
("Error connecting to database");
mysql_select_db ("computer_room,$db");
$result = mysql_query("SELECT * FROM users WHERE name ='".$user."'AND password=PASSWORD('".$pass."')");

if (!$result){
echo "Sorry, there has been a technical error. You cannot enter";
exit;
}
if(mysql_num_rows($result)>0){
$logged_in_user =$user;
session_register(logged_in_user);
echo "Welcome to Computer Room Equipment Database";
exit;
}
else {
echo "Your Login attempt failed";
}
}
else if ($user || $pass){
echo "Please fill in bothe fields<br>";
}
?>

thanks

<form action="login.php" method="post" enctype="text/plain">
Your Username:
<input type="text" name="user" value="" size="40" maxlength="40"/>
<br>
Your Password:

<input type="text" name="pass" value="" size="40" maxlength="40"/>
<br>

<input type="submit" name="" value="Login"/>



</form>

</body>
</html>

[/php]
Feb 14 '08 #5
ronverdonk
4,258 Expert 4TB
Where did you put the statements that pick up the userid and password from the $_POST array. Because you did a POST on that form.
So you'll have to start your script with something (but not exactly) like
[php]
if (isset($_POST['user'] AND isset($_POST['pass'])) {
$user=strip_tags($_POST['user']);
$pass=strip_tags($_POST['pass');
//
// cleanse and check validity of the POSTed fields to avoid any attacks
//
}
[/php]
Btw: what is this statement doing?? Does not look quite correct. What databasename is 'computer_room,$db' ?
[php]
mysql_select_db ("computer_room,$db");
[/php]

Ronald
Feb 14 '08 #6
Thanks.. it Work fine..
Feb 18 '08 #7
ronverdonk
4,258 Expert 4TB
Thanks.. it Work fine..
Good that it works. Could you please share with us how you solved your problem? Thanks and see you again.

Ronald
Feb 18 '08 #8
It work by putting a statement to pick up the user and pass from the $_POST.

Thanks Ronald.

Code: ( php )
if (isset($_POST['user'] AND isset($_POST['pass'])) {
$user=strip_tags($_POST['user']);
$pass=strip_tags($_POST['pass');
//
// cleanse and check validity of the POSTed fields to avoid any attacks
//
}
Feb 19 '08 #9
ronverdonk
4,258 Expert 4TB
Ok you got it. See you next time here.

Ronald
Feb 19 '08 #10

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

Similar topics

4
by: ja | last post by:
Hello, When I run the following query: select count(*) from table111 where pf = 'F' and pet = 'Y' I get the following error message:
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
3
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2...
14
by: Hemant Shah | last post by:
Folks, I installed DB2 UDB 8.2 FP8 ESE on Win 2K syatem. I cataloged node and database on AIX system. When I try to connect to the database on windows system from an AIX system I get following...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
0
by: nleesy | last post by:
Our web application running on WebSphere hits the following two exceptions randomly (once or twice a day) while opening connection to db2. Does anyone has idea about the cause of the exception. We...
5
by: Frank Swarbrick | last post by:
Has anyone come upon this problem? My DB2/LUW 9.1 database seems to be both "started and not started". Check out the following: C:\Program Files\IBM\SQLLIB\BIN>db2 connect to sample SQL1032N ...
6
by: Hemant Shah | last post by:
Folks, I am having hard time figuring out the problem I have with setting up new DB2 instance. This is 22nd instance I am creating on the server and I have never encounterd this problem. My...
0
by: pratush | last post by:
hi friends, Can anyone tell me what is wrong with this in IBM DB2 7.2. I am getting a problem while creating a local database through stored procedure . i am add it manually and giving the TCP\ip...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.