473,386 Members | 1,795 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,386 software developers and data experts.

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

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($link);
?>


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 1707
phpmaet
27
Hi,
please note what error you have?

thanks
Sep 12 '06 #2
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
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
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 ...
2
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...
18
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...
5
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...
14
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"?>...
3
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...
3
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...
4
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
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
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...
0
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
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...

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.