473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Login script which only works some of the time...?

5 New Member
Hi

I wrote a very basic login script which acesses a mySQL database, like this:-


<?php

// compares values entered in login page form with mySQL database,
and then
directs either to protected page or to a failure page

$em = trim($_POST['email']);
$pw = trim($_POST['password']);

$link = mysql_connect ('server', 'account', 'password');
mysql_select_db ("database1" );


// if $em and $pw match a record, then display page, else display
failure page

$query = "SELECT email, password FROM details_table WHERE (email
= '$em'
AND password = '$pw')";

$result = mysql_query ($query);

if (mysql_num_rows ($result) == 1)
{
require('http://www.homesite/redirect.php');
}
else
{
echo"login failed";
}


mysql_close($li nk);
?>


My problem is this :-

It worked fine on my localhost test system, and fine on the first remote server/ database combination I put it on.

However, I have since tried to reuse it, calling other tables on the same database, other databases, and on other servers using other databases - and it does not work on these, although it is still runnng fine on the original configuration

Does anyone have have any ideas about why this might be, or whether there is another, more solid way of achieving what this script does ( bearing in mind I am trying to keep it as simple as possible for the moment?
Sep 10 '06 #1
2 1749
phpmaet
27 New Member
Hi,
please note what error you have?

thanks
Sep 12 '06 #2
dubdave
5 New Member
Hi

It doen't post any mySQL error code - it just runs the 'login failed' part of the script - as though it couldn't access the database

I have a version of it working fine on a server right now - but if I try to rewrite it to access another table in the same database, or another database, it just runs straight to the login failed page

I have spent two days trying every variation of the script - different databases, different tables - changing only one thing at a time - and I know it works because the version I have posted is running fine....

Any thoughts on this would be most welcome - or an alternate script for this simple job which works - I have tried some others i have seen posted and tey don't seem to run at all
Sep 12 '06 #3

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

Similar topics

3
2864
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"); ?>
7
1535
by: Cemal Karademir | last post by:
Hi, I'm workin on a small Login page/program with asp.net. It uses an MS-Access database that looks like this: USERID | NAME | PASSWORD _________________________________ 1 | John | hello 2 | Paul | hello2 I don't understand why it doesn't work. I think i'm doing something wrong
2
1493
by: Assimalyst | last post by:
Hi, I am creating a website where i want to allow some webforms to be accessible to all users, and those in a subdirectory available only to authenticated users. I have created a script to authenticate users from a stored sql database from a login page login.aspx. private void Submit1_ServerClick(object sender, System.EventArgs e)
18
3386
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password and those sessions are tracked individually. Some suggest create table fields with the session ID...
5
2439
by: Kivak Wolf | last post by:
Hi, I am currently trying to make a website that requires an account to use so it can disply the data according to the account. I have ASP.NET 2.0 installed and working fine. However, it is not my server, I am having a company host it. I know that you can use the "Login" control right in VS2005, but it won't work unless the website is on localhost. Where can I find a good place to get or find out how to make a login control from...
14
8625
victorduwon
by: victorduwon | last post by:
Hi guys and gals, I am using javascript to autologin to my google analytics account via a hyperlink. This is what the text looks like this <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
3
1137
by: harsh9892991141 | last post by:
every time enter my login id and password in my index page it shows me the error 404 Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 127.0.0.1
3
6219
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it has to tell then them its wrong information but currently it takes then to a next page and then tells them its incorrect information. This is tedious as every time they enter wrong they will be redirected to a different page and then they have to...
4
3680
by: adam.waterfield | last post by:
I am just wondering if anyone here can help with a problem that we have here. We have a PHP based website/application that has a user login that is connected to our AD setup. This works fine. Obviously their usernames and passwords are common to their exchange mailbox ones. What we would like to do is just have the one common login for our web application. I can obviously get their username/password in login to the site, encrypt and...
0
8444
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, 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...
0
8356
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,...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
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...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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();...
0
4198
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 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.