473,508 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

login form does not output error messages

2 New Member
I have some problem this code. plz check and correct this code. My problem is If write wrong user id and password automatically enter my url not show the error message invalid user id or password.plz solve my problem early send my email full code using this database.

this is login page code login.php
Expand|Select|Wrap|Line Numbers
  1.  //Database Information
  2.  
  3. $dbhost = "localhost";
  4. $dbname = "_MUNGED_";
  5. $dbuser = "_MUNGED_";
  6. $dbpass = "_MUNGED_";
  7.  
  8. //Connect to database
  9.  
  10. mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
  11. mysql_select_db($dbname) or die(mysql_error());
  12.  
  13. session_start();
  14. $username = $_POST[‘username’];
  15. $password = md5($_POST[‘password’]);
  16.  
  17. $query = “select * from users where username=’$username’ and password=’$password’”;
  18.  
  19. $result = mysql_query($query);
  20.  
  21. if (mysql_num_rows($result) = 0) {
  22. $error = “Bad Login”;
  23.     include “login.html”;
  24.  
  25. } else {
  26.     $_SESSION[‘username’] = “$username”;
  27.     include “memberspage.php”;
  28. }
  29.  
  30. ?>
Aug 23 '07 #1
2 1394
ak1dnar
1,584 Recognized Expert Top Contributor
Welcome to TSDN.

You have to echo the error messages.
Expand|Select|Wrap|Line Numbers
  1. echo $error;
Aug 23 '07 #2
pbmods
5,821 Recognized Expert Expert
Heya, DeepG. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'problem' actually get FEWER responses?).

I went ahead and removed the database login info from your post for your protection.

TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.

Good idea to put your content on a separate page from the backend. Since you're already doing that, consider using header() redirection instead of include() so as to get rid of the annoying "Are you sure you want to resubmit POST data?" browser warning when the User refreshes the page or presses the back button.
Aug 23 '07 #3

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

Similar topics

5
4246
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
3
2835
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
4
3414
by: XP | last post by:
I am having problems with the blow page. I have a login page where I enter the userid and password. This then connects to this page. If I enter the userid and password correctly, it prints...
3
1954
by: Shabam | last post by:
I know that dotnet allows for form field validation. However I'm looking to customize the error message display and am wondering if it's possible to do what I need. Example: Suppose in a...
10
4484
by: et | last post by:
I have an asp.net program that uses a connection string, using integrated security to connect to a sql database. It runs fine on one server, but the other server gives me the error that "Login...
0
1592
by: bp_jobemail | last post by:
I'm trying to use PHP to wrap the output of an HTML form before it goes into a precompiled C cgi script. Essentially, the company that I work for uses a purchased precompiled c program for their...
2
2373
by: drah | last post by:
Hello not exactly sure if it is a php script problem or a database/table issue i apologize if i'mposting in wrong category. I was asked to put a login script on a site for someone and i made the...
6
3320
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
4
8573
by: Freedolen | last post by:
Hi All, I had a perl script which is used to login in a web page, but it gives the error as "301 Moved Permanently". What does this means and how can it be rectified? Can anyone help on this? ...
0
7229
marktang
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,...
0
7398
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...
1
7061
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
5637
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,...
1
5057
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...
0
3208
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...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
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...

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.